Bringing the tools together

posted in owl's Blog
Published May 27, 2011
Advertisement
It all started with the UI library. Then it followed the skeletal animation loader. After that the model visualizer. The scene partitioning and the level editor.

Then there was a little lapse to implement lua scripting.

As the "game" is going to be "tile" based I'm needing to also make a tileset editor. At this point, having a model visualizer, a level editor and a tileset editor being three different apps makes little sense in relation to "handyness" so I decided put them all together in one app.

In the UI library there is a new control called "panel" which is simply a window without decorations. In order to have three different sections in the "Game Editor" I need three of those that should get activated, say by pressing the Fs keys. F1: Level Editor, F2: Tileset Editor, F3: Model Visualizer.

So the application module in the Lua script would look something like this:

[source lang="cpp"]

----------------------------------------------------------------------
--
-- Application
--
----------------------------------------------------------------------
dofile "lua_section_level.lua"
dofile "lua_section_tileset_editor.lua"
dofile "lua_section_model_editor.lua"

------------------------------------------------------------------
-- Configure
------------------------------------------------------------------
function application_configure()

end
------------------------------------------------------------------
-- Init
------------------------------------------------------------------
function application_init()
owl.set_clear_color(0.5,0.5,0.5,1.0)

gui.screen_viewport:set(0, 0, screen_width, screen_height, -1.0, 1.0 )
gui.root:resize (screen_width, screen_height)
gui.fonts:load("zekton.ttf")
gui.fonts:load("arial.ttf")
gui.theme:load("theme.xml")
gui.default_font = gui.fonts:get("zekton", 11)

level:init()
tileset_editor:init()
model_editor:init()
end
------------------------------------------------------------------
-- Update
------------------------------------------------------------------
function application_update()
gui:update(app.clock:get_ticks());
end
------------------------------------------------------------------
-- Draw
------------------------------------------------------------------
function application_draw()
owl.set_foreground_color(1.0,1.0,1.0,1.0)
owl.clear_color_buffer();
owl.clear_depth_buffer();
gui:draw()
end
------------------------------------------------------------------
-- Key Press
------------------------------------------------------------------
function application_keypress()
key = input.keyboard.key

if (key==27) then -- ESC
app:quit()
elseif (key==282) then -- F1
level:visible(true)
tileset_editor:visible(false)
model_editor:visible(false)
elseif (key==283) then -- F2
level:visible(false)
model_editor:visible(false)
tileset_editor:visible(true)
elseif (key==284) then -- F3
level:visible(false)
tileset_editor:visible(false)
model_editor:visible(true)
else
print(key)
end
end
------------------------------------------------------------------
-- Initialization
------------------------------------------------------------------
app:on_configure("application_configure")
app:on_init("application_init")
app:on_update("application_update")
app:on_draw("application_draw")
app:on_key_press("application_keypress")
[/source]

And the "sections" initialization something like

[source lang="cpp"]

------------------------------------------------------------------
-- Init
------------------------------------------------------------------
function level:init()
level.panel = owl.create_panel(script, gui.root)
level.panel:resize(gui.root:get_width(),gui.root:get_height())
level.panel:on_update("level::update")
level.panel:on_draw("level::draw")
level.panel:on_key_press("level::key_press")
level.panel:on_key_release("level::key_release")
level.panel:focus()
level.panel:background_color(0,0,0,255)
level.world = owl.create_world()

level.menubar = owl.create_menubar(script, level.panel:to_object())
level.menu = level.menubar:add_menu("Level")
option = level.menu:add_option("New Level", "level::dummy")
option = level.menu:add_option("Load Level", "level::dummy")
option = level.menu:add_option("Save Level", "level::dummy")
[/source]

So far it's coming along quite nicely. I'm getting stuck at making the tile picker control as I'm afraid I'm going to have to write a special c++ class to handle that and I'm not sure where in the library to put it, as everything in it is directly game-related and not for tools. I might create a sub-namespace for game::tools but I haven't decided it yet.

On the dark side of the story, the SWIG c++ interface output file is becoming a HUGE monster (2.5 MB of source code!) and while I now can code stuff without recompiling, compiling times have increased pretty bad. I might split the interface file in little pieces but that would add complexity at the time of compiling too. I need to think of this deeply and try to make a good decision.

The video shows nothing new except for the three things working together in the same app.

[media]
[/media]


On another note, this blog has become my personal rubber duck to help me look at the project from another perspective. It has become helpful too in the sense that having to post some progress on a weekly basis makes it feel like a sort of dead line and pushes me forward at achieving results. Please keep reading so I can keep advancing! And Thanks! :)
1 likes 2 comments

Comments

JTippetts
I know the feeling. The tolua++ binding file for my noise library is getting pretty big. I keep dumping all the new modules I code for it in there out of habit.
May 28, 2011 04:47 AM
a_insomniac
Wow this is pretty cool! You have put quite a bit of work into this. Keep it going for sure.
BTW, nice touch with music...that alone will get most people through to the end [img]http://public.gamedev.net/public/style_emoticons/default/cool.gif[/img]
May 28, 2011 11:33 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement