Skip to content

Commit

Permalink
Added a completely new GUI, and a new doc file
Browse files Browse the repository at this point in the history
    Important internal changes:
    * Most GUI callbacks are now methods of their HudSystems (cleans the code, mostly)
    * Saving/Loading has been disconnected from GUI for now, since we need to redesign how saving/loading works anyway.
    * CEGUIWindow now supports animations (which are used slightly)
    * A small change to microbe.lua, adding a species name. This is temporary, as the entire data-passing system needs to be changed (see Revolutionary-Games#240)

    See Revolutionary-Games#130
  • Loading branch information
Moopli committed Dec 29, 2014
1 parent 7488252 commit 6ec06a9
Show file tree
Hide file tree
Showing 11 changed files with 361 additions and 197 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ assets/*
# We want certain xmls though
!assets/definitions/
!assets/definitions/*.xml
# maybe add these in later
!assets/gui/layouts/*.layout

# Website directory

Expand Down
27 changes: 27 additions & 0 deletions doc/quicktips.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#Quick Tips for Navigating the Source

Most current work happens in Lua, with C++ development generally providing little more than interfaces to CEGUI, Ogre, and all the other parts of the engine.

Before you begin, Google "Ogre3D", "CEGUI", "luabind", and "Entity Component System" so you know what they are.

*Last Updated: Dec 27, 2014

#Lua
* Lua files are loaded into the engine in the order specified in the manifests.
* So, for any two files, the second one implicitly includes the first.
* The main_menu, microbe_stage, and microbe_editor each have some structure in common:
* The foo_hud.lua file defines the interactions with the GUI.
* Each defines a FooHudSystem, simple ECS Systems that have no components (yet, anyway).
* The :init method runs on program startup, and in these Systems sets up the callbacks for each button, and maybe saves a bit of extra state.
* The :update method runs every turn of the game loop
* See src/gui/CEGUIWindow.h for more details on the CEGUI features we currently have a Lua interface for.
* Each folder also has a setup.lua file, which, naturally, does necessary setup for the game mode. They define two important things:
* The necessary setup functions, that are called on startup
* a small function at the end which calls Engine:createGameState, defining:
* The Systems which will run in this GameState (and their order)
* The setup function, which for simplicity just calls the functions defined above
* The rest of the files in the subfolders contain more specific bits of functionality:
* Organelles are defined in microbe_stage/, each file defining a class for a certain type of organelle, and factory functions for all the different organelles of that type.
* Organelles are created by calling OrganelleFactory:makeOrganelle(data) -- the OrganelleFactory takes care of finding the right function
* The code for Microbes is overall currently a bit messy, and will probably change soon.
* The other files not in a subfolder define more general utility things -- hex coordinate math, lua interpretation in the in-game console, etc. Read as you need.
2 changes: 2 additions & 0 deletions ogre_cfg/resources.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ FileSystem=../gui/layouts
FileSystem=../gui/looknfeel
[Schemes]
FileSystem=../gui/schemes
[Animations]
FileSystem=../gui/animations

[General]
# Keep this last so it overrides everything before
Expand Down
6 changes: 3 additions & 3 deletions scripts/main_menu/main_menu_hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ end
function MainMenuHudSystem:init(gameState)
System.init(self, gameState)
local root = gameState:rootGUIWindow()
local microbeButton = root:getChild("Background"):getChild("MicrobeButton")
local microbeEditorButton = root:getChild("Background"):getChild("MicrobeEditorButton")
local quitButton = root:getChild("Background"):getChild("QuitButton")
local microbeButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("NewGameButton")
local microbeEditorButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("EditorMenuButton")
local quitButton = root:getChild("Background"):getChild("MainMenuInteractive"):getChild("ExitGameButton")

microbeButton:registerEventHandler("Clicked", mainMenuMicrobeStageButtonClicked)
microbeEditorButton:registerEventHandler("Clicked", mainMenuMicrobeEditorButtonClicked)
Expand Down
16 changes: 15 additions & 1 deletion scripts/microbe_editor/microbe_editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
--------------------------------------------------------------------------------
class 'MicrobeEditor'

FLAGELIUM_MOMENTUM = 12.5
FLAGELIUM_MOMENTUM = 12.5 -- what the heck is this for, and why is it here?

function MicrobeEditor:__init(hudSystem)
self.currentMicrobe = nil
Expand Down Expand Up @@ -102,6 +102,8 @@ function MicrobeEditor:enqueueAction(action)
while #self.actionHistory > self.actionIndex do
table.remove(self.actionHistory)
end
self.hudSystem.undoButton:enable()
self.hudSystem.redoButton:disable()
action.redo()
table.insert(self.actionHistory, action)
self.actionIndex = self.actionIndex + 1
Expand All @@ -117,6 +119,12 @@ function MicrobeEditor:undo()
end
self.actionIndex = self.actionIndex - 1
end
-- nothing left to undo? disable undo
if self.actionIndex <= 0 then
self.hudSystem.undoButton:disable()
end
-- upon undoing, redoing is possible
self.hudSystem.redoButton:enable()
end

function MicrobeEditor:redo()
Expand All @@ -128,6 +136,12 @@ function MicrobeEditor:redo()
self.mutationPoints = self.mutationPoints - action.cost
end
end
-- nothing left to redo? disable redo
if self.actionIndex >= #self.actionHistory then
self.hudSystem.redoButton:disable()
end
-- upon redoing, undoing is possible
self.hudSystem.undoButton:enable()
end

function MicrobeEditor:getMouseHex()
Expand Down
Loading

0 comments on commit 6ec06a9

Please sign in to comment.