Browse Source

small update

Ethosa 4 years ago
parent
commit
e49bfd2b41
3 changed files with 15 additions and 3 deletions
  1. 2 1
      README.md
  2. 2 1
      engine/scenes/projects/project_template.nim
  3. 11 1
      src/nodesnim/window.nim

+ 2 - 1
README.md

@@ -75,7 +75,7 @@ This section contains links to documentation for all nodes.
 |[Vector3][]     |                     |[VSlider][]           |                    |                    |                    |
 |[SceneBuilder][]|                     |[Popup][]             |                    |                    |                    |
 |[StyleSheet][]  |                     |[TextureButton][]     |                    |                    |                    |
-|                |                     |[TextureProgressBar][]|                    |                    |                    |
+|[TileSet][]     |                     |[TextureProgressBar][]|                    |                    |                    |
 |                |                     |[Counter][]           |                    |                    |                    |
 |                |                     |[Switch][]            |                    |                    |                    |
 |                |                     |[SubWindow][]         |                    |                    |                    |
@@ -141,6 +141,7 @@ Use the [`Nim compiler user guide`](https://nim-lang.org/docs/nimc.html#dynlibov
 [SceneBuilder]:https://ethosa.github.io/nodesnim/nodesnim/core/scene_builder.html
 [Font]:https://ethosa.github.io/nodesnim/nodesnim/core/font.html
 [StyleSheet]:https://ethosa.github.io/nodesnim/nodesnim/core/stylesheet.html
+[TileSet]:https://ethosa.github.io/nodesnim/nodesnim/core/tileset.html
 
 [Node]:https://ethosa.github.io/nodesnim/nodesnim/nodes/node.html
 [Canvas]:https://ethosa.github.io/nodesnim/nodesnim/nodes/canvas.html

+ 2 - 1
engine/scenes/projects/project_template.nim

@@ -28,4 +28,5 @@ project@on_process(self):
 
 project@on_click(self, x, y):
   changeScene("Editor", @[(k: "title", v: self.getNode("Title").LabelRef.getText())])
-  glutReshapeWindow(1280, 720)
+  resizeWindow(1280, 720)
+  centeredWindow()

+ 11 - 1
src/nodesnim/window.nim

@@ -166,7 +166,9 @@ proc motion(x, y: cint) {.cdecl.} =
   current_scene.handleScene(last_event, mouse_on, paused)
 
 
-# ---- Public ---- #
+
+# -------------------- Public -------------------- #
+
 proc addScene*(scene: SceneRef) =
   ## Adds a new scenes in app.
   ##
@@ -186,6 +188,11 @@ proc addMainScene*(scene: SceneRef) =
     scenes.add(scene)
   main_scene = scene
 
+proc centeredWindow* =
+  var dm: DisplayMode
+  discard getCurrentDisplayMode(0, dm)
+  windowptr.setPosition((dm.w/2 - width/2).cint, (dm.h/2 - height/2).cint)
+
 proc changeScene*(name: string, extra: seq[tuple[k: string, v: string]] = @[]): bool {.discardable.} =
   ## Changes current scene.
   ##
@@ -207,6 +214,9 @@ proc changeScene*(name: string, extra: seq[tuple[k: string, v: string]] = @[]):
   when defined(debug):
     debug("result of `changeScene` is ", result)
 
+proc resizeWindow*(x, y: cint) =
+  windowptr.setSize(x, y)
+
 proc setMainScene*(name: string) =
   ## Set up main scene.
   ##