소스 검색

Added windowFixed macro to disable window resizing. (#678)

Paul Gillis 5 년 전
부모
커밋
fa2ac3eba0
2개의 변경된 파일8개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 2
      hxd/System.hl.hx
  2. 5 3
      hxd/Window.hl.hx

+ 3 - 2
hxd/System.hl.hx

@@ -87,6 +87,7 @@ class System {
 		var height = 600;
 		var size = haxe.macro.Compiler.getDefine("windowSize");
 		var title = haxe.macro.Compiler.getDefine("windowTitle");
+		var fixed = haxe.macro.Compiler.getDefine("windowFixed") == "1";
 		if( title == null )
 			title = "";
 		if( size != null ) {
@@ -98,10 +99,10 @@ class System {
 		#if hlsdl
 			sdl.Sdl.init();
 			@:privateAccess Window.initChars();
-			@:privateAccess Window.inst = new Window(title, width, height);
+			@:privateAccess Window.inst = new Window(title, width, height, fixed);
 			init();
 		#elseif hldx
-			@:privateAccess Window.inst = new Window(title, width, height);
+			@:privateAccess Window.inst = new Window(title, width, height, fixed);
 			init();
 		#else
 			@:privateAccess Window.inst = new Window(title, width, height);

+ 5 - 3
hxd/Window.hl.hx

@@ -33,15 +33,17 @@ class Window {
 
 	static var CODEMAP = [for( i in 0...2048 ) i];
 
-	function new(title:String, width:Int, height:Int) {
+	function new(title:String, width:Int, height:Int, fixed:Bool = false) {
 		this.windowWidth = width;
 		this.windowHeight = height;
 		eventTargets = new List();
 		resizeEvents = new List();
 		#if hlsdl
-		window = new sdl.Window(title, width, height);
+		final sdlFlags = if (!fixed) sdl.Window.SDL_WINDOW_SHOWN | sdl.Window.SDL_WINDOW_RESIZABLE else sdl.Window.SDL_WINDOW_SHOWN;
+		window = new sdl.Window(title, width, height, sdl.Window.SDL_WINDOWPOS_CENTERED, sdl.Window.SDL_WINDOWPOS_CENTERED, sdlFlags);
 		#elseif hldx
-		window = new dx.Window(title, width, height);
+		final dxFlags = if (!fixed) dx.Window.RESIZABLE else 0;
+		window = new dx.Window(title, width, height, dx.Window.CW_USEDEFAULT, dx.Window.CW_USEDEFAULT, dxFlags);
 		#end
 	}