Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

Commit

Permalink
Added UI Dropdowns and migrated to custom SDL bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
aplerdal committed Feb 19, 2024
1 parent fb644c4 commit 5723c99
Show file tree
Hide file tree
Showing 25 changed files with 11,616 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/[Bb]in/
/[Oo]bj/
/[Ll]ib/
/.vs/
/.vscode/
*.gba
Expand Down
42 changes: 40 additions & 2 deletions AdvancedEdit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platforms>AnyCPU;x86</Platforms>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<Compile Remove="SDL2-CS-master\**" />
<EmbeddedResource Remove="SDL2-CS-master\**" />
<None Remove="SDL2-CS-master\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NativeFileDialog.Extended" Version="1.1.2" />
<PackageReference Include="Sayers.SDL2.Core" Version="1.0.11" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="SDL2-CS-master\SDL2-CS.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,6 +28,36 @@
</ItemGroup>

<ItemGroup>
<None Update="Font\roboto.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\LICENSE.freetype.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\LICENSE.harfbuzz.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\LICENSE.zlib.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\README-SDL.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\README-SDL_image.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\README.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\SDL2.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\SDL2_image.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="lib\SDL2_ttf.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="test.bmp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
20 changes: 20 additions & 0 deletions AdvancedEdit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,42 @@ VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdvancedEdit", "AdvancedEdit.csproj", "{6A1A77BA-4E3B-4388-B027-B065F0688375}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SDL2-CS.Core", "SDL2-CS-master\SDL2-CS.Core.csproj", "{23C740EE-99D5-4A32-92FC-5D79409303D8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Debug|x64.ActiveCfg = Debug|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Debug|x64.Build.0 = Debug|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Debug|x86.ActiveCfg = Debug|x86
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Debug|x86.Build.0 = Debug|x86
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Release|Any CPU.Build.0 = Release|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Release|x64.ActiveCfg = Release|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Release|x64.Build.0 = Release|Any CPU
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Release|x86.ActiveCfg = Release|x86
{6A1A77BA-4E3B-4388-B027-B065F0688375}.Release|x86.Build.0 = Release|x86
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Debug|Any CPU.ActiveCfg = Debug|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Debug|Any CPU.Build.0 = Debug|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Debug|x64.ActiveCfg = Debug|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Debug|x64.Build.0 = Debug|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Debug|x86.ActiveCfg = Debug|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Debug|x86.Build.0 = Debug|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Release|Any CPU.ActiveCfg = Release|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Release|Any CPU.Build.0 = Release|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Release|x64.ActiveCfg = Release|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Release|x64.Build.0 = Release|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Release|x86.ActiveCfg = Release|x64
{23C740EE-99D5-4A32-92FC-5D79409303D8}.Release|x86.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file added Font/roboto.ttf
Binary file not shown.
18 changes: 11 additions & 7 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ class Program{
public static IntPtr Window = IntPtr.Zero;
public static int WindowWidth, WindowHeight;

public static IntPtr Font = IntPtr.Zero;

public static Dictionary<int, bool> keyDown = new Dictionary<int, bool>();
public static Dictionary<int, bool> keyPress = new Dictionary<int, bool>();
public static Dictionary<int, bool> keyReleased = new Dictionary<int, bool>();
static unsafe void Main(string[] args){

#region Init SDL
// Initilizes SDL.
if (SDL_Init(SDL.SDL_INIT_VIDEO) < 0) Console.WriteLine($"There was an issue initilizing SDL. {SDL_GetError()}");
if (SDL_Init(SDL_INIT_VIDEO) < 0) Console.WriteLine($"There was an issue initilizing SDL. {SDL_GetError()}");

// Create a new window given a title, size, and passes it a flag indicating it should be shown.
Window = SDL_CreateWindow("AdvancedEdit", SDL_WINDOWPOS_UNDEFINED, SDL.SDL_WINDOWPOS_UNDEFINED, 1024, 1024, SDL_WindowFlags.SDL_WINDOW_RESIZABLE | SDL_WindowFlags.SDL_WINDOW_SHOWN);
Expand Down Expand Up @@ -54,9 +56,11 @@ static unsafe void Main(string[] args){
}
}

SDL_GetWindowSize(Window, out WindowWidth, out WindowHeight);
SDL_ttf.TTF_Init();
Font = SDL_ttf.TTF_OpenFont("Font/roboto.ttf",12);

TrackEditor trackEditor = new TrackEditor();
UIManager uiManager = new UIManager();

// Main loop for the program
var running = true;
Expand All @@ -71,23 +75,23 @@ static unsafe void Main(string[] args){
}
while (SDL_PollEvent(out SDL_Event e) == 1)
{
uiManager.ElementEvents(e);
trackEditor.Events(e);
switch (e.type)
{
case SDL_EventType.SDL_QUIT:
running = false;
break;
case SDL_EventType.SDL_MOUSEBUTTONUP:
trackEditor.MouseUp(e);
//trackEditor.MouseUp(e);
break;
case SDL_EventType.SDL_MOUSEBUTTONDOWN:
trackEditor.MouseDown(e);
//trackEditor.MouseDown(e);
break;
case SDL_EventType.SDL_MOUSEWHEEL:
trackEditor.ScrollWheel(e);
//trackEditor.ScrollWheel(e);
break;
case SDL_EventType.SDL_MOUSEMOTION:
trackEditor.MouseMotion(e);
//trackEditor.MouseMotion(e);
break;
case SDL_EventType.SDL_KEYDOWN:
if (keyDown[(int)e.key.keysym.sym] == false)
Expand Down
5 changes: 5 additions & 0 deletions SDL2-CS-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
*.pidb
*.userprefs
*.suo
25 changes: 25 additions & 0 deletions SDL2-CS-master/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* SDL2# - C# Wrapper for SDL2
*
* Copyright (c) 2013-2024 Ethan Lee.
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from
* the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software in a
* product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
* Ethan "flibitijibibo" Lee <[email protected]>
*
*/
33 changes: 33 additions & 0 deletions SDL2-CS-master/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Makefile for SDL2#
# Written by Ethan "flibitijibibo" Lee

# Source Lists
SRC = \
src/SDL2.cs \
src/SDL2_gfx.cs \
src/SDL2_image.cs \
src/SDL2_mixer.cs \
src/SDL2_ttf.cs

# Targets

debug: clean-debug
mkdir -p bin/Debug
cp app.config bin/Debug/SDL2-CS.dll.config
mcs /unsafe -debug -out:bin/Debug/SDL2-CS.dll -target:library $(SRC)

clean-debug:
rm -rf bin/Debug

release: clean-release
mkdir -p bin/Release
cp app.config bin/Release/SDL2-CS.dll.config
mcs /unsafe -optimize -out:bin/Release/SDL2-CS.dll -target:library $(SRC)

clean-release:
rm -rf bin/Release

clean: clean-debug clean-release
rm -rf bin

all: debug release
43 changes: 43 additions & 0 deletions SDL2-CS-master/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
This is SDL2#, a C# wrapper for SDL2.

Project Website: https://github.com/flibitijibibo/SDL2-CS

License
-------
SDL2 and SDL2# are released under the zlib license. See LICENSE for details.

About SDL2
----------
For more information about SDL2, visit the SDL wiki:

http://wiki.libsdl.org/moin.fcg/FrontPage

About the C# Wrapper
--------------------
The C# wrapper was written to be used for FNA's platform support. However, this
is written in a way that can be used for any general C# application.

The wrapper provides bindings for the following libraries:
- SDL2
- SDL2_gfx
- SDL2_image
- SDL2_mixer
- SDL2_ttf

Note that SDL2# will not provide every single SDL2 function. This is due to
limitations in the C# language that would cause major conflicts with the native
SDL2 library and its extensions.

SDL2# is a pure port of the C headers. The naming schemes for this library will
be exactly as they are done in the C library, with little-to-no concern for
"appropriate" C# style. The namespace indicates that this is SDL2, the class
names will indicate which library file the function/type/value exists in, and
everything else will be as close to the C version as technically possible.

About the Visual Studio Debugger
--------------------------------
When running C# applications under the Visual Studio debugger, native code that
names threads with the 0x406D1388 exception will silently exit. To prevent this
exception from being thrown by SDL, add this line before your SDL_Init call:

SDL.SDL_SetHint(SDL.SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
32 changes: 32 additions & 0 deletions SDL2-CS-master/SDL2-CS.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
<AssemblyName>SDL2-CS</AssemblyName>
<RootNamespace>SDL2</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<IsTrimmable>true</IsTrimmable>
<EnableAOTAnalyzer>true</EnableAOTAnalyzer>
</PropertyGroup>
<PropertyGroup>
<SDLSettingsPropsFilePath>$(SolutionDir)SDL2-CS.Settings.props</SDLSettingsPropsFilePath>
</PropertyGroup>
<Import Project="$(SDLSettingsPropsFilePath)" Condition="Exists('$(SDLSettingsPropsFilePath)')" />
<Target Name="ValidatePropsFilePath" BeforeTargets="BeforeBuild">
<Message Importance="High" Text="No property overrides found at '$(SDLSettingsPropsFilePath)'" Condition="!Exists('$(SDLSettingsPropsFilePath)')" />
<Message Importance="High" Text="Loaded property overrides from '$(SDLSettingsPropsFilePath)'" Condition="Exists('$(SDLSettingsPropsFilePath)')" />
</Target>
<ItemGroup>
<Compile Include="src\SDL2.cs" />
<Compile Include="src\SDL2_gfx.cs" />
<Compile Include="src\SDL2_image.cs" />
<Compile Include="src\SDL2_mixer.cs" />
<Compile Include="src\SDL2_ttf.cs" />
</ItemGroup>
</Project>
Loading

0 comments on commit 5723c99

Please sign in to comment.