Tutorial request : Chili custom commandbar/buildbar

Tutorial request : Chili custom commandbar/buildbar

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
sunspot
Posts: 104
Joined: 09 Jun 2011, 12:17

Tutorial request : Chili custom commandbar/buildbar

Post by sunspot »

Hey guys,

I've been researching this a bit trying to find good examples in existing mods and the forum posts but I don't seem to be getting anywhere. A few things I have learned

*CtrlPanel.txt , can be used to create an extra column or so but nothing special
*You can hide the resourcebar and command bar with a bit of simple code

Code: Select all

local HiddenCommands = {
   [CMD.MOVE] = true,
   [CMD.WAIT] = true,
   [CMD.STOP] = true,
   [CMD.FIGHT] = true,
   [CMD.ATTACK] = true,
   [CMD.PATROL] = true,
   [CMD.RECLAIM] = true,   
   [CMD.LOAD_UNITS] = true,
   [CMD.LOAD_UNITS] = true,
   [CMD.UNLOAD_UNITS] = true, 
   [CMD.GUARD] = true,
   [CMD.REPEAT] = true, 
   --   [CMD.MOVE_STATE] = true,
--   [CMD.FIRE_STATE] = true,
   [CMD.CLOAK] = true,
   [CMD.AUTOREPAIRLEVEL] = true,
   [CMD.IDLEMODE] = true,
}

function widget:CommandsChanged()
    local cmds = widgetHandler.commands
    local n = widgetHandler.commands.n
    for i=1,n do
      if (HiddenCommands[cmds[i].id]) then
         cmds[i].hidden = true
      end
    end
end
So I'm at a point where I don't have any commands anymore on screen ... which is good so I have a clean slate to start from. But now what ? I tried a few things, with this in mind (take note the following is pseudocode)

Code: Select all

local commandwindow
local buildbarwindow
local screen
initwidget(){
  commandwindow = new chiliwindow()
  buildbarwindow = new chiliwindow()
  screen.add(commandwindow)
  screen.add(buildbarwindow)
}

onSelectUnit(unit){
  availablecommands = unit.getAvailableCommands()
  availabebuildings = unit.getAvailableBuildings()
  foreach(command :  availablecommands ){
    uiCommand = new uiCommand(command)
    commandWindow.add(uiCommand,x,y)
  }
  foreach(building:  availabebuildings ){
    uiBuilding= new uiBuilding(building)
    buildbarwindow .add(uiBuilding,x,y)
  }
  screen.repaint()
}
as I said pseudocode but I hope it works like this a bit at least. Can any ChiliUi developer give me a hand or get me started with an example script ?
sunspot
Posts: 104
Joined: 09 Jun 2011, 12:17

Re: Tutorial request : Chili custom commandbar/buildbar

Post by sunspot »

It's been a few days now, and I've learned quite a bit I don't need this tutorial anymore. In fact I wrote a basic one of my own. Can you tell me what you think of it , before I write the next more advanced once with text changing and commands in a seperate window

http://springrts.com/wiki/UI:Development
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Tutorial request : Chili custom commandbar/buildbar

Post by knorke »

good job :)
Maybe rename the page though, UI:Development sounds more like UI in general while this is specific to chili.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Tutorial request : Chili custom commandbar/buildbar

Post by FLOZi »

Yeah, I'd suggest: Chili-HelloWorld as the page name. (We really need to decide on some standards re. :, _, - use in wiki page names)

You should also learn to use the <code> and <pre> tags, I might take a look at sprucing it up and correcting any English errors. Great work though! :-)
sunspot
Posts: 104
Joined: 09 Jun 2011, 12:17

Re: Tutorial request : Chili custom commandbar/buildbar

Post by sunspot »

FLOZi wrote:Yeah, I'd suggest: Chili-HelloWorld as the page name. (We really need to decide on some standards re. :, _, - use in wiki page names)

You should also learn to use the <code> and <pre> tags, I might take a look at sprucing it up and correcting any English errors. Great work though! :-)
Well i'm planning on writing 2 more tutorials one for changing text dynamicly ingame on a label. And one to put commands in a seperate window. So it has to be something more general then Chili-HelloWorld :)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Tutorial request : Chili custom commandbar/buildbar

Post by knorke »

imo make a page chiliUIGuide that gives general info, setup, links and then have it link to sub pages named ie helloWorldWithchiliUI, commandWindowWithchiliUI,...
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Tutorial request : Chili custom commandbar/buildbar

Post by FLOZi »

I would match the pattern we have established with CEG, Animation-COB and Animation-LuaScripting. (I plan to match this pattern with the new Unit-UnitDefs etc pages)

i.e.
Chili-Overview
Chili-HelloWorld
Chili-DynamicLabel
Chili-CommandWindow
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Tutorial request : Chili custom commandbar/buildbar

Post by knorke »

yes, agree with flozi. just had forgetten - and _ work in page names.
Saw you made Lesson_1_:_Hello_World, imo always prefix with chiliUI or similiar, otherwise it gets confusing if there is a guide on something else. (ie mapping)

Also I would not include numbers in the page name, ordering can be done by the "chili main page" that links all those guides.
So Chili-HelloWorld instead of Lesson_1_:_Hello_World
sunspot
Posts: 104
Joined: 09 Jun 2011, 12:17

Re: Tutorial request : Chili custom commandbar/buildbar

Post by sunspot »

knorke wrote:yes, agree with flozi. just had forgetten - and _ work in page names.
Saw you made Lesson_1_:_Hello_World, imo always prefix with chiliUI or similiar, otherwise it gets confusing if there is a guide on something else. (ie mapping)

Also I would not include numbers in the page name, ordering can be done by the "chili main page" that links all those guides.
So Chili-HelloWorld instead of Lesson_1_:_Hello_World
ah yeah, well I called it lesson 1 because you will need to follow them in that order to keep up with the advanced stuff. I'm working on the next lesson now.
sunspot
Posts: 104
Joined: 09 Jun 2011, 12:17

Re: Tutorial request : Chili custom commandbar/buildbar

Post by sunspot »

lesson 2 is ready any feedback is appreciated
Post Reply

Return to “Game Development”