Game Development Community

Two Bitmap Arrays in one GUI Control Class Help!

by Justin DuJardin · in Torque Game Engine · 05/13/2002 (2:58 am) · 3 replies

Recently i've begun converting some of the base GUI Control classes to skinnable counter-parts; All has gone well with the exception of the GuiPopUpCtrl. My problem with this control is that, when giving it a bitmap array for it's own use, i've had to, in script replace the

bitmap = "./darkScroll";

with my own bitmap array for the control

bitmap = "./legendsPopupMenu";

The control, for those of you that aren't familiar with it, is basically a drop-down combobox, why it's named PopUpMenu I have no idea. In the GuiProfile it uses darkScroll (the scrollbar bitmap array image) for when you click on the control, it creates a drop-down menu and uses the image for the scrollbar portion of the control. I tried adding another field to the control's script profile, but to no avail. Before explaining any further, i'll provide a snippet of code to 'show' you what i mean.

From "common/ui/defaultProfiles.cs"
if(!isObject(GuiPopUpMenuProfile)) new GuiControlProfile (GuiPopUpMenuProfile)
{
   opaque = true;
   mouseOverSelected = true;
   border = 4;
   borderThickness = 2;
   borderColor = "0 0 0";
   fontSize = 14;
   fontColor = "0 0 0";
   fontColorHL = "32 100 100";
   fontColorSEL = "32 100 100";
   fixedExtent = true;
   justify = "center";
   [b]bitmap = "./legendsPopupMenu"; 
   scrollBitmap = "./darkScroll";[/b]
   hasBitmapArray = true;
};

I added the scrollBitmap field in code as follows

From "engine\gui\guiPopUpCtrl.h"

class GuiPopUpMenuCtrl : public GuiTextCtrl
{
...
  protected:
   [b]StringTableEntry mScrollBitmap;[/b]
...

and in "engine\gui\guiPopUpCtrl.cc"

void GuiPopUpMenuCtrl::initPersistFields(void)
{
   Parent::initPersistFields();
   
   addField("maxPopupHeight",           TypeS32,          Offset(mMaxPopupHeight, GuiPopUpMenuCtrl));
   [b]addField("scrollBitmap",        TypeFilename,   Offset(mScrollBitmap, GuiPopUpMenuCtrl));[/b]
}

When the control adds the children controls, a background, textlist, and a scrollcontrol it copies the profile of the object to the scrollcontrol, then attempts to construct the bitmap array from the profiles image info. I attempted to then (after copying the profile) overwrite the image information with the mScrollBitmap StringTableEntry.

From "engine\gui\guiPopUpCtrl.cc"
//------------------------------------------------------------------------------
void GuiPopUpMenuCtrl::addChildren()
{
   mTl = new GuiPopUpTextListCtrl(this);
   AssertFatal(mTl, "Failed to create the GuiPopUpTextListCtrl for the PopUpMenu");
   mTl->mProfile = mProfile;
   mTl->setField("noDuplicates", "false");

   mSc = new GuiScrollCtrl();
   AssertFatal(mSc, "Failed to create the GuiScrollCtrl for the PopUpMenu");
   mSc->mProfile = mProfile;

[b]   //mSc->mProfile->mBitmapName = mScrollBitmap;
   mSc->mProfile->setField("bitmap",mScrollBitmap);[/b]
   mSc->setField("hScrollBar","AlwaysOff");
   mSc->setField("vScrollBar","dynamic");

   mBackground = new GuiPopUpBackgroundCtrl(this, mTl);
   AssertFatal(mBackground, "Failed to create the GuiBackgroundCtrl for the PopUpMenu");
}

Even, by setting the field manually (because the scrollBitmap seems to always equal NULL) to my image's path, i still receive errors when trying to construct the bitmap array. I debugged into the code and the object that reaches the mProfile->constructBitmapArray(); in the scroll control's ::onWake() procedure still contains the original image's file path. Any incite as to what I may be doing wrong would be unbelievably appreciated.

Regards and thanks in advance,

Justin 'av0n' DuJardin

#1
05/14/2002 (3:12 pm)
*bump* Anyone? Please?
#2
05/14/2002 (3:24 pm)
mm... you really don't want to do that... messing with the profile's bitmap is not a good idea - it gets loaded only when the profile is first refCounted from a control's onWake, for instance. A better way to solve the problem would be to add your popup's bitmap array entries to the end of the scroll control's.
#3
05/14/2002 (4:25 pm)
Roger that Mark, I was thinking of doing that earlier but was hesitant because i'm working on a skinnable interface such as the one presented by justin mette. While it's not a huge problem to have the two control's bitmaps in one file, I prefer to keep each seperate if possible.