Merge pull request #486 from aaronfranke/os-test

Add Mono C# preprocessor defines, README, and screenshots to OS testing demo
This commit is contained in:
Aaron Franke
2020-06-24 03:14:28 -04:00
committed by GitHub
11 changed files with 256 additions and 9 deletions

93
misc/os_test/MonoTest.cs Normal file
View File

@@ -0,0 +1,93 @@
using Godot;
using System;
public class MonoTest : Node
{
public string Architecture()
{
#if GODOT_ARM64 || GODOT_ARM64_V8A
return "64-bit ARM";
#elif GODOT_ARMV7 || GODOT_ARMEABI_V7A
return "32-bit ARM";
#elif GODOT_X86_64
return "64-bit x86";
#elif GODOT_X86
return "32-bit x86";
#elif GODOT_128
return "128-bit";
#elif GODOT_64
return "64-bit";
#elif GODOT_32
return "32-bit";
#else
return "Unknown";
#endif
}
public string OperatingSystem()
{
#if GODOT_WINDOWS
return "Windows";
#elif GODOT_LINUXBSD || GODOT_X11
return "Linux (or BSD)";
#elif GODOT_SERVER
return "Server (Linux or BSD)";
#elif GODOT_MACOS || GODOT_OSX
return "macOS";
#elif GODOT_ANDROID
return "Android";
#elif GODOT_IOS
return "iOS";
#elif GODOT_HTML5
return "HTML5";
#elif GODOT_HAIKU
return "Haiku";
#elif GODOT_UWP
return "UWP (Windows 10)";
#else
return "Unknown";
#endif
}
public string PlatformType()
{
#if GODOT_PC
return "PC";
#elif GODOT_MOBILE
return "Mobile";
#elif GODOT_WEB
return "Web";
#elif GODOT
return "Godot Editor (not exported)";
#else
return "Unknown";
#endif
}
public string TextureCompression()
{
string compression = "";
#if GODOT_S3TC
compression += "S3TC";
#endif
#if GODOT_ETC
if (compression.Length > 0)
{
compression += ", ";
}
compression += "ETC";
#endif
#if GODOT_ETC2
if (compression.Length > 0)
{
compression += ", ";
}
compression += "ETC2";
#endif
if (compression.Length > 0)
{
return compression;
}
return "Not exported or no textures";
}
}

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Tools</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{780B9CDA-51E7-446A-816F-0E2CF667C96C}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputPath>.mono/temp/bin/$(Configuration)</OutputPath>
<RootNamespace>OperatingSystemTesting</RootNamespace>
<AssemblyName>Operating System Testing</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<GodotProjectGeneratorVersion>1.0.7374.17554</GodotProjectGeneratorVersion>
<BaseIntermediateOutputPath>.mono/temp/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
<ApiConfiguration Condition=" '$(Configuration)' != 'Release' ">Debug</ApiConfiguration>
<ApiConfiguration Condition=" '$(Configuration)' == 'Release' ">Release</ApiConfiguration>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Tools|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<DefineConstants>$(GodotDefineConstants);GODOT;DEBUG;TOOLS;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="GodotSharp">
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="GodotSharpEditor" Condition=" '$(Configuration)' == 'Tools' ">
<HintPath>$(ProjectDir)/.mono/assemblies/$(ApiConfiguration)/GodotSharpEditor.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="MonoTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Operating System Testing", "Operating System Testing.csproj", "{780B9CDA-51E7-446A-816F-0E2CF667C96C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Tools|Any CPU = Tools|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{780B9CDA-51E7-446A-816F-0E2CF667C96C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{780B9CDA-51E7-446A-816F-0E2CF667C96C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{780B9CDA-51E7-446A-816F-0E2CF667C96C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{780B9CDA-51E7-446A-816F-0E2CF667C96C}.Release|Any CPU.Build.0 = Release|Any CPU
{780B9CDA-51E7-446A-816F-0E2CF667C96C}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
{780B9CDA-51E7-446A-816F-0E2CF667C96C}.Tools|Any CPU.Build.0 = Tools|Any CPU
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,25 @@
using System.Reflection;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("Operating System Testing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

37
misc/os_test/README.md Normal file
View File

@@ -0,0 +1,37 @@
# Operating System Testing
This demo showcases various OS-specific features in Godot.
It can be used to test Godot while porting it to a
new platform or to check for regressions.
In a nutshell, this demo shows how you can get information from the
operating system, or interact with the operating system.
Language: GDScript and some [C#](https://docs.godotengine.org/en/latest/getting_started/scripting/c_sharp/index.html)
(Mono is NOT required to run this demo)
Renderer: GLES 2
## How does it work?
The [`OS`](https://docs.godotengine.org/en/latest/classes/class_os.html)
class provides an abstraction layer over the platform-dependent code.
OS wraps the most common functionality to communicate with the host
operating system, such as the clipboard, video driver, date and time,
timers, environment variables, execution of binaries, command line, etc.
The buttons are connected to a node with the `actions.gd` script, which
perform actions using the OS class.
The text on the left is filled in using the `os_test.gd` script,
which gathers information about the OS using the OS class.
On a Mono-enabled version of Godot, Godot will load `MonoTest.cs` into
the `MonoTest` node. Then, information determined by
[`C# preprocessor defines`](https://docs.godotengine.org/en/latest/getting_started/scripting/c_sharp/c_sharp_features.html#preprocessor-defines)
will be added to the left panel.
## Screenshots
![Top HiDPI](screenshots/top-hidpi.png)
![Mono](screenshots/mono.png)

View File

@@ -1,4 +1,4 @@
extends VBoxContainer
extends Node
func _on_OpenShellWeb_pressed():

View File

@@ -1,6 +1,7 @@
extends Panel
extends Node
onready var rtl = $HBoxContainer/Features
onready var mono_test = $MonoTest
# Returns a human-readable string from a date and time, date, or time dictionary.
@@ -98,6 +99,13 @@ func _ready():
add_line("Value of `PATH`", OS.get_environment("PATH"))
add_line("Value of `path`", OS.get_environment("path"))
add_header("Hardware")
add_line("Model name", OS.get_model_name())
add_line("Processor count", OS.get_processor_count())
add_line("Device unique ID", OS.get_unique_id())
add_line("Video adapter name", VisualServer.get_video_adapter_name())
add_line("Video adapter vendor", VisualServer.get_video_adapter_vendor())
add_header("Input")
add_line("Latin keyboard variant", OS.get_latin_keyboard_variant())
add_line("Device has touch screen", OS.has_touchscreen_ui_hint())
@@ -107,16 +115,19 @@ func _ready():
add_header("Localization")
add_line("Locale", OS.get_locale())
add_header("Hardware")
add_line("Model name", OS.get_model_name())
add_line("Processor count", OS.get_processor_count())
add_line("Device unique ID", OS.get_unique_id())
add_line("Video adapter name", VisualServer.get_video_adapter_name())
add_line("Video adapter vendor", VisualServer.get_video_adapter_vendor())
add_header("Mobile")
add_line("Granted permissions", OS.get_granted_permissions())
add_header("Mono (C#)")
var mono_enabled = ResourceLoader.exists("res://MonoTest.cs")
add_line("Mono module enabled", "Yes" if mono_enabled else "No")
if mono_enabled:
mono_test.set_script(load("res://MonoTest.cs"))
add_line("Architecture", mono_test.Architecture())
add_line("Operating System", mono_test.OperatingSystem())
add_line("Platform Type", mono_test.PlatformType())
add_line("Texture Compression", mono_test.TextureCompression())
add_header("Software")
add_line("OS name", OS.get_name())
add_line("Process ID", OS.get_process_id())

View File

@@ -196,6 +196,8 @@ margin_bottom = 514.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "Kill Current Process"
[node name="MonoTest" type="Node" parent="."]
[connection signal="pressed" from="HBoxContainer/Actions/GridContainer/OpenShellWeb" to="HBoxContainer/Actions" method="_on_OpenShellWeb_pressed"]
[connection signal="pressed" from="HBoxContainer/Actions/GridContainer/OpenShellFolder" to="HBoxContainer/Actions" method="_on_OpenShellFolder_pressed"]
[connection signal="pressed" from="HBoxContainer/Actions/GridContainer/ChangeWindowTitle" to="HBoxContainer/Actions" method="_on_ChangeWindowTitle_pressed"]

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB