I'm studying physics at the University of Vienna and trying to get into OpenGL/GLSL programming lately. I began to mod Freelancer some years ago and lastly I joined the Universe Modding Crew that focuses on modding Sci-Fi games. Our current project is "Stargate: Revenge of the Fallen", a Stargate mod for Battlefield 2142. Besides, I try to develop a Spacesim-Engine that can simulate (special) relativistic effects in a realtime application. (Check out my YouTube channel: Copycap) Hopefully I will update progress on both on my Blog. :) If you have questions, feel free to contact me via Email or Jabber (I actually don't like ICQ/MSN ;)

Report RSS Python and HUD Builder Project

Posted by on

So I started to get into python by reading some basic tutorial to learn the syntax. I'm not an python expert now, but I can get things working, and that's all that I want for the moment. In near future it will definitly be a good idea to be able to connect python and C++, 'cause Battlefield's .tweak and .con files are all written in python-like manner.

Some days ago, I started to alter the F302's HUD for testing purposes and I found it annoying to edit all nodes and variables by hand with a text editor (though vim is a big improvement from blank notepad). So I decided to write a GUI Tool in Python, that will let us develop new HUDs easily. I'm using wxPython for my GUI. The reason why I'm using python is just the same fact as stated above: the hudfiles are mostly simple python-scripts. There you have something like the following code:

hudBuilder.createSplitNode		VehicleHuds F302Hud_Base
hudBuilder.setNodeLogicShowVariable 	EQUAL GuiIndex 700

hudBuilder.createSplitNode		F302Hud_Base F302Hud
hudBuilder.setNodeLogicShowVariable 	EQUAL GuiIndex 700
hudBuilder.addNodeBlendEffect		7 2

hudBuilder.createPictureNode		F302Hud F302LeftFrame 147 105 136 390
hudBuilder.setPictureNodeTexture 	Ingame\Vehicles\Icons\Hud\Air\Attack\gunship\EU\leftFrame.tga
hudBuilder.setNodeColor		 	1 0.706 0 1

This is just a code snippet from the current F302Pilot-HUD. As I understand that, the script uses a hudBuilder-class (probably a wrapper class), where you can attach several different nodes with specific variables. With that hudBuilder you build up a tree containing all the nodes. So what I'm doing now is just the same: I used a wx.TreeCtrl object and added a rootnode, than the user can do a right-click onto the node and choose from several options, for example "Add Node". A list shows up and the user can select which node to be added to the selected node. The nodes will later be linked with other GUI-Objects, that will be displayed in the actual Program-Window, that represents the player's screen. For example the PictureNode will be coupled with an object that holds that picture and can be moved to a specific position (by mouse or keys, or just autoset). I did not think about the actual implementation now, it may get a bit tricky, but I hope I can get it to work as I want.

What I'm working on at the moment is some kind of "properties-window\" that shows the node's logical and other variables. This should hopefully not be such a big problem. The thing where it will get a bit nasty is file i/o. It should be possible for the user to at least save the whole tree in the .con format that the hudBuilder class can understand and interpret right. At the moment I have no idea how I will implement that, I did not look up python's I/O routines yet, just got a little idea of it. After I completed the "saving" part, it may be easy to implement an actual "loading" routine, so that existing trees can also be loaded back into the program. Would be stupid if the program would not offer that task.

I have much more things going through my mind and I got a pretty good idea of what the program should look like at the end, so hopefully I will be able to get this done quick so I can return back to the MapExplorer Project - there are also the first animations to be done for the mod, so got a bunch of work to do. See you next time!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: