Vertical ProgressBar?

Black'Tea

08-03-2008 16:08:58

Is there a way to display the progressbar vertically?

edit: and how to set a texture for the progressbar?

kungfoomasta

08-03-2008 19:14:43

I don't have the code on hand, so I don't know the function names. I'm guessing they are something like:

ProgressBar::setOrientation - vertical or horizontal progress
ProgressBar::setFillDirection - positive to negative, or negative to positive.

The fill direction lets you specify wether you want a horizontal bar to grow from the left or right, and whether you want a vertical bar to grow from the top or bottom.

To create a texture for the progressbar, you need to create 2 images:

1. <skin name>.progressbar.png
2. <skin name>.progressbar.bar.png

Both images should be the same size in pixels, but the bar will be transparent except for where the actual bar is. The bar should be at 100% progress. Refer to the progressbar textures given.

Hope that helps. :)

Black'Tea

08-03-2008 19:35:01

setLayout(QuickGUI::ProgressBar::Layout::LAYOUT_VERTICAL);
->found it!

Can you please go in details how to use a texture on a progressbar? I´m not good on these Skin-things ;)
I want to use your default-progressbars. I don´t want the green progressbar, but the blue one.

kungfoomasta

08-03-2008 22:09:01

I'm in the process of making things easier to skin, including a slight revamp on the skinning system and the addition of the skinset editor. For right now, you substitute in the blue progress bar images to the skinset by:

1. Deleting the Skinset.qgui.png and qgui.skinset files.
2. Replace qgui.progressbar.png and qgui.progressbar.bar.png with the blue ones. (same name)
3. Run the demo, it will recreate the skinset files deleted in step 1.

Black'Tea

09-03-2008 12:30:47

ok, I also want the green one ;)

I will take care of it later.
I have another problem. How can I test if there´s already a progressbar? I only have the name of this progressbar and I tried this, but I think it doesen´t work:

bool QuickGuiManager::IsProgressBarthere(Ogre::String Name)
{
QuickGUI::ProgressBar* pgb = NULL;
pgb = static_cast<QuickGUI::ProgressBar*>(mGameSheet->getChildWidget(Name));
if (pgb == NULL)
return false;
if (pgb != NULL)
return true;
}

kungfoomasta

09-03-2008 18:07:39

getChildWidget is no longer recursive, you'll need to use the findWidget function. See if that works out.

Black'Tea

12-03-2008 18:20:05

I have updatet QuickGUI and there is more trouble than befor...

Ogre::LogManager::getSingleton().logMessage("IsProgressBarthere");
Ogre::LogManager::getSingleton().logMessage(Name);
QuickGUI::ProgressBar* pgb = NULL;
pgb = static_cast<QuickGUI::ProgressBar*>(mGameSheet->findChildWidget(Name));
if (pgb == NULL)
{
Ogre::LogManager::getSingleton().logMessage("ProgressBar is not available!");
return false;
}
if (pgb != NULL)
{
Ogre::LogManager::getSingleton().logMessage("ProgressBar is available!");
return true;
}
Ogre::LogManager::getSingleton().logMessage("IsProgressBarthere END");
return false;


All the time "ProgressBar is not available!" is in the log... I don´t know why, I´ve created the progressbar I´m searching for.

By the way, my Highscore-sheet isn´t displayed anymore... since I´ve updated. Also don´t know why. Have you change sth. with clipping or something else?

kungfoomasta

12-03-2008 20:09:59

I don't have the code on hand (at work), but isn't there a "findWidget" function? The difference between findChildWidget and findWidget is that findChildWidget only searching through immediate children. If you want a recursive search use findWidget.

Black'Tea

13-03-2008 14:30:21

I don´t think so. I´ve updatet and there isn´t a function called findWidget, is it?

kungfoomasta

13-03-2008 16:42:48


- Changed getChildWidget to findChildWidget which searches recursively for a child
- Added getChildWidget which only looks for a child among it's children.


This was a patch I applied made by Kali, so its in there, but I didn't have the names correct.

Can you post your code that creates the ProgressBar and the Highscore-sheet?

Black'Tea

13-03-2008 17:28:09

ProgressBar:
void QuickGuiManager::AddProgressBar(Ogre::String Name, Ogre::String tex, float x, float y, float width, float height)
{
QuickGUI::ProgressBar* pgb = mGameSheet->createProgressBar(Name);
pgb->setPosition( mRoot->mCamera->getViewport()->getActualWidth() * x,
mRoot->mCamera->getViewport()->getActualHeight() * y);
pgb->setWidth( mRoot->mCamera->getViewport()->getActualWidth() * width);
pgb->setHeight( mRoot->mCamera->getViewport()->getActualHeight() * height);
pgb->setClippingEdge(QuickGUI::ProgressBar::ClippingEdge::CLIP_LEFT_BOTTOM);
pgb->setFillDirection(QuickGUI::ProgressBar::FillDirection::FILLS_NEGATIVE_TO_POSITIVE);

pgb->setInitialPixelOffset(0);
pgb->setProgress(1.0f);
pgb->show();
}


Highscoresheet (I removed unimportant things):

void QuickGuiManager::SetupHighscore(bool background)
{
mGUI->getMouseCursor()->show();
/*...*/
mHighscoreSheet = mGUI->createSheet();

/*...*/

//Backgroundwindow
mHighscoreWindow = mHighscoreSheet->createWindow();
mHighscoreWindow->setPosition(mRoot->mCamera->getViewport()->getActualWidth() * 0.2,
mRoot->mCamera->getViewport()->getActualHeight() * 0.2);
mHighscoreWindow->setWidth(mRoot->mCamera->getViewport()->getActualWidth() * 0.6);
mHighscoreWindow->setHeight(mRoot->mCamera->getViewport()->getActualHeight() * 0.6);
mHighscoreWindow->show();
mHighscoreWindow->hideSkin();
mHighscoreWindow->hideTitlebar();

/*...*/

QuickGUI::Label* MainLabel = mHighscoreWindow->createLabel();
MainLabel->setPosition(mHighscoreWindow->getWidth() * 0.2,
mHighscoreWindow->getHeight() * 0.07 );
MainLabel->setWidth( mHighscoreWindow->getWidth() * 0.6);
MainLabel->setHeight( mHighscoreWindow->getHeight() * 0.1);
MainLabel->setFont(Cache::Instance().mRoot->mSettings.Menu);
MainLabel->setTextColor(Cache::Instance().mRoot->mSettings.MenuC);
MainLabel->setText("Highscore");
MainLabel->setTextBounds(QuickGUI::Point(0,0),QuickGUI::Size(MainLabel->getWidth(),MainLabel->getHeight()));
MainLabel->show();
MainLabel->hideSkin();

for (int i=0;i<10;i++)
{
QuickGUI::Label* Label = mHighscoreWindow->createLabel();
Label->setPosition(mHighscoreWindow->getWidth() * 0.1,
mHighscoreWindow->getHeight() * 0.2 + mHighscoreWindow->getHeight() * (0.65 * i / 10));
Label->setWidth( mHighscoreWindow->getWidth() * 0.3);
Label->setHeight( mHighscoreWindow->getHeight() * 0.08);
Label->setFont(Cache::Instance().mRoot->mSettings.Menu);
Label->setText(iNames->c_str());
Label->setTextColor(Cache::Instance().mRoot->mSettings.MenuC);
Label->setTextBounds(QuickGUI::Point(0,0),QuickGUI::Size(Label->getWidth(),Label->getHeight()));
Label->show();
Label->hideSkin();

QuickGUI::Label* Label2 = mHighscoreWindow->createLabel();
Label2->setPosition(mHighscoreWindow->getWidth() * 0.6,
mHighscoreWindow->getHeight() * 0.2 + mHighscoreWindow->getHeight() * (0.65 * i / 10));
Label2->setWidth( mHighscoreWindow->getWidth() * 0.3);
Label2->setHeight( mHighscoreWindow->getHeight() * 0.08);
Label2->setFont(Cache::Instance().mRoot->mSettings.Menu);
Label2->setText(iPoints->c_str());
Label2->setTextColor(Cache::Instance().mRoot->mSettings.MenuC);
Label2->setTextBounds(QuickGUI::Point(0,0),QuickGUI::Size(Label2->getWidth(),Label2->getHeight()));
Label2->show();
Label2->hideSkin();

iPoints++;
iNames++;
}

QuickGUI::Button* BhighscoreEND = mHighscoreWindow->createButton("Highscore");
BhighscoreEND->setPosition(mHighscoreWindow->getWidth() * 0.4,
mHighscoreWindow->getHeight() * 0.88);
BhighscoreEND->setWidth( mHighscoreWindow->getWidth() * 0.2);
BhighscoreEND->setHeight( mHighscoreWindow->getHeight() * 0.08);
BhighscoreEND->setText("Ok");
BhighscoreEND->addEventHandler(QuickGUI::Widget::EVENT_MOUSE_CLICK,&QuickGuiManager::SetupMenu,this);
BhighscoreEND->setTextBounds(QuickGUI::Point(0,0),QuickGUI::Size(BhighscoreEND->getWidth(),BhighscoreEND->getHeight()));
BhighscoreEND->setFont(Cache::Instance().mRoot->mSettings.Menu);
BhighscoreEND->setTextColor(Cache::Instance().mRoot->mSettings.MenuC);
BhighscoreEND->show();
BhighscoreEND->hideSkin();

mGUI->setActiveSheet(mHighscoreSheet);

if (background == false) // some game specific ...
{
mGameSheet->removeAndDestroyAllChildWidgets();
mGUI->destroySheet(mGameSheet);
}
}

kungfoomasta

13-03-2008 18:01:23

mGameSheet->removeAndDestroyAllChildWidgets();

This would remove the Progress Bar. I made this mistake in my own project. Ideally each game state will have its own sheet, and you can just make the call to "mGUIManager->setActiveSheet(mySheet1);" whenever you need to switch sheets.

Black'Tea

13-03-2008 20:41:00

mGameSheet->removeAndDestroyAllChildWidgets();

This would remove the Progress Bar. I made this mistake in my own project. Ideally each game state will have its own sheet, and you can just make the call to "mGUIManager->setActiveSheet(mySheet1);" whenever you need to switch sheets.


Sry, but these problems are two different problems in two different sheets. The problem with the highscore appears since I´ve updated QuickGUI.

My main problem now is that I can´t get a progressbar via findChildWidget/getChildWidget since I´ve updated QuickGUI and before this, I could get the progressbar via getChildWidget, but I couldn´t (and now too) proof if a progressbar is already in use.

I hope you can understand my problems

kungfoomasta

14-03-2008 05:14:19

Sorry, there was a simple mistake, findChildWidget was not really recursive, and didn't look past immediate children. This has been fixed and committed to SVN.

Regarding your sheet not displaying properly, do you change screen resolutions? I'm not sure why it wouldn't be visible. One change I made to sheets is that the constructor takes a default size. If you create the sheet from the guimanager and don't specify the sheet's size, it takes the same size as the viewport. The reason for this feature is so you can create a sheet with a certain size in mind, ie 800 x 600, even if the current window is not 800 x 600. When a sheet becomes the active sheet it will be resized to have the same dimensions as the viewport. Anchoring and scroll bars may influence the positioning of widgets. I don't really think this is related to your issue, but I'm not sure why it wouldn't be showing up. :?

Black'Tea

14-03-2008 13:02:08

you already said something to
mGameSheet->removeAndDestroyAllChildWidgets();
but i thought it wouldn´t effekt, because I destroy another sheet.

I wanted to destroy, when the highscore sheet is loaded, the gamesheet (and also the progressbars in it!), but it seems that it destroys the Highscoresheet, too! Now I put the code before creating my highscoresheet, this works. But removeAndDestroyAllChildWidgets doesn´t work as it shall, does it?

Edit:
I can´t still proof if a progressbar is in use, also with findChildWidget() (I´ve updated). When I use this code:

bool QuickGuiManager::IsProgressBarthere(Ogre::String Name)
{
QuickGUI::ProgressBar* pgb = NULL;
pgb = static_cast<QuickGUI::ProgressBar*>(mGameSheet->findChildWidget(Name));
if (pgb == NULL)
{
Ogre::LogManager::getSingleton().logMessage("ProgressBar isn´t available!");
return false;
}
if (pgb != NULL)
{
Ogre::LogManager::getSingleton().logMessage("ProgressBar is available!");
return true;
}
return false;
}


always false returns and in the log still is "ProgressBar isn´t available!".
This means, that static_cast<QuickGUI::ProgressBar*>(mGameSheet->findChildWidget(Name));
must return NULL and I don´t know why!

Edit:

bool QuickGuiManager::IsProgressBarthere(Ogre::String Name)
{
if (mGameSheet->isChild(static_cast<QuickGUI::ProgressBar*>(mGameSheet->getChildWidget(Name))) == true)
return true;
return false;
}


This did it! :)

kungfoomasta

14-03-2008 18:18:53

removeAndDestroyAllChildWidgets should not affect any other sheets, I don't see how that would be possible. The sheet is the top node of the widget hierarchy, managed by the GUIManager.

When I get a chance I'll create a sheet with a progressbar on it and test the findChildWidget function.