CEGUIBuildDialog         CEGUI dialog which displays rotating 3D meshes on multiple buttons
Print

Introduction

The code presented here will create a CEGUI dialog box with multiple pushbuttons, each displaying a single rotating 3D mesh, as shown in the following image

 
DialogBuild.jpg

 
IMPORTANT

 

Dialog source code and Layout

 

 

DialogBuild.layout

Section "Build/Cancel"

Sections "Build/Structures", "Build/BioUnits", "Build/Mechs", and "Build/Vehicles"

Section "Build/Scrollbar"

Sections "Build/Button00" - "Build/Button21"

Sections "Build/ButtonLabel00" - "Build/ButtonLabel21"

Sections "Build/ButtonText00" - "Build/ButtonText21"

DialogBuild.h

The first thing in this file that may need to be changed are two #defines
DIALOG_BUTTON_COLUMNS and DIALOG_BUTTON_ROWS.
Next are the IDs for the itemType buttons
buttonStructuresID, buttonBioUnitsID, buttonMechsID, and buttonVehiclesID.
If you do change these, the event handlers will also need to be changed/added
handleButtonStructures, handleButtonBioUnits...

DialogBuild.cpp

#include "InputHandler.h"
#include "PlayState.h"
#include "Common/StaticEntity.h"
#include "Common/EntityMgr.h"
#define INITIAL_ITEM_TYPE     ItemType_Building

DialogBuild::DialogBuild

Probably the only thing needing changing here are the itemType button event handlers
rootWindow->getChild(buttonStructuresID)->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButtonStructures, this));
rootWindow->getChild(buttonBioUnitsID)->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButtonBioUnits, this));
rootWindow->getChild(buttonMechsID)->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButtonMechs, this));
rootWindow->getChild(buttonVehiclesID)->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButtonVehicles, this));
If you change the number of buttons on the dialog, then the handlers for those will also need changing accordingly
rootWindow->getChild(buttonID[0])->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButton00, this));
rootWindow->getChild(buttonID[1])->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButton01, this));
rootWindow->getChild(buttonID[2])->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButton02, this));
rootWindow->getChild(buttonID[3])->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButton03, this));
rootWindow->getChild(buttonID[4])->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButton04, this));
rootWindow->getChild(buttonID[5])->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&DialogBuild::handleButton05, this));

 

DialogBuild::~DialogBuild

DialogBuild::HandleKeyDownEvents

DialogBuild::FrameStarted(Real timeElapsed)

DialogBuild::preRenderTargetUpdate

Also in this function is more game-specific code
global->rootNode->setVisible(false);

DialogBuild::postRenderTargetUpdate

Similar to DialogBuild

DialogBuild::handleScrollChanged

DialogBuild::handleButtonCancel

DialogBuild::handleButtonStructures

DialogBuild::handleButtonBioUnits

DialogBuild::handleButtonMechs

DialogBuild::handleButtonVehicles

DialogBuild::handleButton00 - DialogBuild::handleButton05

Each handler hides the dialog box, then calls the game-specific code
and is initialized in the function DialogBuild

DialogBuild::InitializeForItemType

The following section of code in this function will have to be changed to work with your game framework
EntityTemplate *  entityTemplate;
 
   // Count the total number of Entities eligible to be displayed in the Build dialog.
   entityCount = 0;
   for (entityIndex = 0; entityIndex < global->entityMgr->GetEntityTemplateCount(); entityIndex++)
      {
      entityTemplate = global->entityMgr->GetEntityTemplateFromIndex(entityIndex);
      if (entityTemplate && (entityTemplate->itemType == itemTypeToDisplay))
         entityCount += 1;
      }

 

DialogBuild::PopulateButtons

DialogBuild::show

DialogBuild::hide

 


Contributors to this page: jacmoe111451 points  and OgreWikiBot .
Page last modified on Saturday 02 of January, 2010 20:22:02 GMT by jacmoe111451 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.