So, I’ve spent the past 3 months doing researches, and trying to build a Graphical User Interface (GUI) for our beloved game engine
After building it (It is called PGUI btw, see in my signature) I realised that it was too complicated.
Then KXGUI came up, it’s easier and based on some fragments of the original source code of PGUI. It’s supposed to be a simpler version of it.
This project is a WIP, so here you can see the current supported (feel free to suggest something!):
Features:
- Multi-resolution: You can get the same widget dimensions on every screen resolution, this was a missing feature on PGUI and you could clearly see that the widgets were too tiny if you played Super RC Boat Racing. Everything now is scaled according to your screen resolution.
- Custom cursors: Another missing feature on PGUI. You can use this if you don’t want to use the hacky “textured plane and logic-bricks” approach. It’s pretty easy to use! See some examples at the end of this post.
Current Screenshot:
Examples:
- Simple Menu:
from kxgui import *
from bge import logic as g
def main(cont):
o = cont.owner
sce = g.getCurrentScene()
if "init" not in o:
o["gui"] = GUI()
o["gui"].addWidget("play" , Button.new(text="Play" , height=0.05), group="menu")
o["gui"].addWidget("options", Button.new(text="Options", height=0.05), group="menu")
o["gui"].addWidget("credits", Button.new(text="Credits", height=0.05), group="menu")
o["gui"].addWidget("exit" , Button.new(text="Exit" , height=0.05), group="menu")
o["gui"].groups["menu"].position = [0.39, 0.35]
o["gui"].applyToScene()
o["init"] = 1
else:
o["gui"].update()
if o["gui"].widgets["exit"].events.clicked:
g.endGame()
- Custom Cursor:
from kxgui import *
from bge import logic as g
def main(cont):
o = cont.owner
sce = g.getCurrentScene()
if "init" not in o:
o["gui"] = GUI()
o["gui"].cursor = Cursor.new(g.expandPath("//cursor1.png"))
o["gui"].addWidget("btn", Button.new(x=0.02, y=0.3))
o["gui"].applyToScene()
o["init"] = 1
else:
o["gui"].update()
You can also change the cursor’s hotspot!
o["gui"].cursor.hotSpot = [0.5, 0.5]
# The "Debug" mode shows the bounds and the hotSpot location of the cursor.
o["gui"].cursor.debug = True
GitHub: https://github.com/DCubix/kxgui
That’s all, I’ll leave a .zip file (containing the blend and some cursors) there for you to test it out! Thanks in advance
Attachments
KXGUI_v0.75.zip (391 KB)KXGUI_v0.75b.zip (695 KB)KXGUI_v0.8.zip (716 KB)