Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - starkhorn

#1
Help requests / ListBox sounds
10 June 2016, 06:21:13
Hi Texus,

So I have a listbox setup fine but I wanted to play a sound when my mouse hovered over an item and also when an item was selected.
Now I think I can trap the item selected easily enough using the ItemSelected signal but what signal can be used when hovering over an item in a listbox? Is it the widgets MouseEntered ? Does that get triggered each time the mouse enters an item?

#2
Hi Texus,

I was using Textboxes but I found I could not alter the colour of specific lines of a text and I could not put them into columns. So instead I have created a panel and adding Labels to the panel.

However one thing that I was missing is that the textbox had a nice border around it's panel. Is there an easy way to add this to a panel?
#3
argghhh - thank you.
#4
Help requests / Re: table widget
26 April 2016, 05:49:09
Hi Texus,

This might be a little beyond me. I'm getting lots of linking errors when trying to copying the table class to my code but I am slowly working through it. However bear with me, I will get back to trying this again.
#5
I'm having trouble getting a scrollbar to appear when adding it to a child window container.
In drawStartTurnSummarySubMenu, I create the child window with the setupChildWindow method.
I then try to add a scrollbar to the child window using setupScrollBarHorz and passing the child window as a container.
I can see that the number of widgets in the child window increases when I add the scrollbar but it never appears. (Note I put autohide to false).
However if I change the line in setupScrollBarHorz

Code (cpp) Select

container->add(scrollbar, scrollBarName);


To the below, the scollbar appears.
Code (cpp) Select

//gui.add(scrollbar, scrollBarName);


However if I move the childwindow the position of the scrollbar doesn't move. Basically I want the scrollbar to control widgets inside a panel which inside a child window. Here are the methods in question.

Code (cpp) Select


void Test::drawStartTurnSummarySubMenu()
{
sf::Vector2i pos(gameWindow.getSize().x * 0.1, gameWindow.getSize().y * 0);
sf::Vector2i size((gameWindow.getSize().x - (gameWindow.getSize().x * 0.25)), gameWindow.getSize().y * 0.750);

setupChildWindow(pos, size, "Start Turn Summary", sf::Color::Red, "startTurn");
tgui::Container::Ptr container = gui.get<tgui::Container>("startTurn");

pos = sf::Vector2i(0, 0);
void (Test::*ptrToMember)(const tgui::Callback&) = NULL; // creating function ptr
ptrToMember = &Test::scrollBarHorzSignalFunction; // assigning function ptr to appropraite function

setupScrollBarHorz("regionPanelScrollHorz", ptrToMember, container);

//clear game window
gameWindow.clear();

gui.draw();
gameWindow.display();
}

void Test::setupChildWindow(sf::Vector2i pos, sf::Vector2i size, string title_text, sf::Color titleText_Color, string passed_childName)
{
if (gui.get(passed_childName) == NULL)
{
tgui::ChildWindow::Ptr childWin = theme->load("ChildWindow");
childWin->setPosition(pos.x, pos.y);
childWin->setSize(size.x, size.y);
childWin->getRenderer()->setTitleColor(titleText_Color);
childWin->setTitle(title_text);
gui.add(childWin, passed_childName);
}
}

bool Test::setupScrollBarHorz(string scrollBarName, void (Test::*ptrToMember)(const tgui::Callback&),tgui::Container::Ptr container)
{
if ((container != NULL && container->get(scrollBarName) == NULL) || (container == NULL && gui.get(scrollBarName) == NULL))
{
tgui::Scrollbar::Ptr scrollbar = theme->load("Scrollbar");
scrollbar->setPosition(container->getPosition() + sf::Vector2f(container->getSize().x, 0));
scrollbar->setSize(20, container->getSize().y);
scrollbar->connectEx("ValueChanged", ptrToMember, this);
scrollbar->setAutoHide(false);
container->add(scrollbar, scrollBarName);
//gui.add(scrollbar, scrollBarName);
return true;
}
else
{
return false;
}
}

void Test::scrollBarHorzSignalFunction(const tgui::Callback& callback)
{
int scrollbarMove = callback.value;
}
#6
Help requests / Re: table widget
22 April 2016, 03:26:11
wow ok, it might take me a while to go through that all but I will give it a go.

One more thing about tables, can you click on a row and trigger an event?
#7
Help requests / table widget
22 April 2016, 01:04:24
Hi Texus,

I was looking at the table.cpp for the new table widget. It looks awesome.

I want to put it into a child window which I can do easily enough but I was wondering if there is a way to get a scroll bar both vertical and horizontal on that?
#8
Table looks awesome. I have a question on it but I'll start a new thread for that :)
#9
Quote from: texus on 28 September 2015, 22:47:16
About the multi-column feature, it has been requested several times with small variations. I guess I will really have to try to add it in 0.7, even though it will be a lot of work to make the widget fit all different use cases.

I think that the first request already dates back 1.5 or even 2 years ago, the github issue is almost a year old as well.

I'll try to make sure that it gets priority and should make it in 0.7-RC, I can't keep delaying it.

Hi Texus,

I know this is an old topic but I was wondering if the above new feature made it into v0.7 release? Specifically the multi-column feature in a listbox.
#10
Actually I should have just tested it before posting....sorry. :(

I had the below and it works fine.

Code (cpp) Select

Button.CustomButtonNonClickRomeHI {
    NormalImage  : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
}


I ensure when setting up the button to call the below to disable, disconnect etc and it works well.

Code (cpp) Select

gui.get(buttonText, true)->disconnectAll();
gui.get(buttonText, true)->disable();
gui.get<tgui::Button>(buttonText, true)->setText("");
#11
Help requests / Optional custom widget config
06 April 2016, 00:58:49
Hi Texus,

I was wondering if you could advise if any of the below config is optional? As you can see I basically want the RGB and image to be the same for normal, hover and down events. I have alot of these widgets to create in the conf file so I was wondering if there was a way to remove optional parameters? i.e. if HoverImage isn't present will it use the normalImage by default etc?

Code (cpp) Select

Button.CustomButtonNonClickRomeHI {
    NormalImage  : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    HoverImage   : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    DownImage    : "..\images\icons\romeNationIcon_v3.png" Part(  56,  0,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(190, 190, 190);
    TextColorDown   : rgb(190, 190, 190);
}
#12
Ok thanks. It might take me a while to download from github and recompile.
I am thinking for right now to create a customer button widget where the hover, normal and down images/rgb are all the same. Also I won't connect any signal function to it....that essentially will just leave an unclickable button.
#13
Ok thanks, I'll give the custom widget a go and see how I get on.

Quote from: texus on 04 April 2016, 11:21:32
It isn't possible directly, Cavas was created exactly for these cases where you needed to do this.

I guess I am struggling now to understand why there is a canvas in order to do sfml sprites, texts etc directly. Is there any reason why we cannot simply draw these items to gui or containers directly, i.e. why the need for an extra layer?

Obviously I know the canvas issue is specific to my graphics card but I would just find it much easier to draw directly to containers rather than needing to have another layer in there.
#14
Help requests / v0.7 using the tgui::picture
05 April 2016, 08:46:32
Hey Texus,

So I want to setup a picture using a texture. However I only want to set the picture to have the picture defined in a sf::IntRect.
Basically I have a sprite that has it's setTextureRect to a subset of a larger texture, and I want the tgui::picture to only display this subset/IntRect.

I don't see a setTextureRect method in tgui::picture so I was wondering if there was a way to do it? Again this is me trying to get around using canvas due to the blinking issue with my graphics card. So instead of sprites, I am trying to use tgui::pictures.
#15
Hi Texus,

Ok so I have replaced nearly all of what I was doing/drawing onto a canvas via labels or pictures. However one thing I cannot seem to replace easily is some sf::RectangleShape onto a child window.

Is there any way to do that in a childwindow without a canvas? I'm assuming no and that I will have to draw a picture with the border outline but I was hoping to avoid that if possible.
#16
arrggh nevermind.

I needed to do this instead, i.e. use *passed_texture instead of passed_texture. Sorry.

Code (cpp) Select

auto picture = std::make_shared<tgui::Picture>(*passed_texture);
#17
Ok thanks. Can I make a create a picture from an existing loaded sf::Texture? I tried the below but I get error

Error   304   error C2664: 'tgui::Picture::Picture(const tgui::Picture &)' : cannot convert argument 1 from 'sf::Texture *' to 'const std::string &'   c:\program files (x86)\microsoft visual studio 12.0\vc\include\memory   932   1   rome_vs2013


Code (cpp) Select

bool drawEngine::setupPicture(sf::Vector2i pos, sf::Vector2i size, string passed_pictureName, sf::Texture *passed_texture, tgui::Container::Ptr container)
{
if ((container != NULL && container->get(passed_pictureName) == NULL) || (container == NULL && gui.get(passed_pictureName) == NULL))
{
auto picture = std::make_shared<tgui::Picture>(passed_texture);
picture->setPosition(pos.x, pos.y);
picture->setSize(size.x, size.y);
if (container == NULL)
{
gui.add(picture, passed_pictureName);
}
else
{
container->add(picture, passed_pictureName);
}

return true;
}

return false;
}

#18
Ok thanks. Driver is already up-to-date. It might be easier for me to avoid using canvas then.

Just to clarify that only canvas uses RenderTexture? So if I convert my SFText to labels then I would not need a canvas as I can draw them directly onto the childwindow container?

Also can childwindows have background image? I don't see that method when I check the methods from the getRenderer() method. Most of the sprites that I am drawing onto the canvas are part of the background image.

Code (cpp) Select

childWin->getRenderer()->
#19
Quote from: texus on 02 April 2016, 23:17:14
There are a few things you could look at:
- What happens if instead of canvases you just create a render texture (call create, clear and display on it)? Does it cause blinking as well?

Ok so I comment out the setupCanvas function and instead I add these lines. I didn't even bother doing a clear or display. The blinking does happen. It is not as pronounced or as bad as when I am doing the setupCanvas but it does happen. (Say a blink of 0.1 seconds as opposed to say 0.4 seconds)

Code (cpp) Select


// create a 500x500 render-texture
sf::RenderTexture renderTexture;
if (!renderTexture.create(500, 500))
{
// error...
}



I haven't tried the other 2 points yet but does the above mean it is an SFML issue?
#20
Quote from: texus on 02 April 2016, 11:42:31
Are you calling canvas->clear() and canvas->display() around your canvas->draw() calls?

I call a canvas->clear() at the beginning.
I then call the below (drawSFTextOnCanvas) multiple times to draw various SFTexts to the canvas.
Then at the end of the method, I call canvas->display.

Code (cpp) Select

void drawEngine::drawSFTextOnCanvas(vector<sf::Text> vectorSFText, tgui::Canvas::Ptr canvas)
{
for (int i = 0; i < vectorSFText.size(); i++)
{
canvas->draw(vectorSFText[i]);
}
}


Now what is strange is if I comment out all drawSFTextOnCanvas, canvas->clear and canvas->display then the issue still happens when all I am doing is creating the canvas. So basically if I just call the below, the blinking happens. It only happens with canvas. Other widgets getting added to the container are fine. I've tried buttons, listboxes and panels.

Code (cpp) Select

//return true if creates new canvas
bool drawEngine::setupCanvas(sf::Vector2i pos, sf::Vector2i size, string passed_canvasName, tgui::Container::Ptr container)
{
if ((container != NULL && container->get(passed_canvasName) == NULL) || (container == NULL && gui.get(passed_canvasName) == NULL))
{
auto canvas = std::make_shared<tgui::Canvas>();
canvas->setPosition(pos.x, pos.y);
canvas->setSize(size.x, size.y);

if (container == NULL)
{
gui.add(canvas, passed_canvasName);
}
else
{
container->add(canvas, passed_canvasName);
}

return true;
}

return false;
}

#21
So I have a strange issue and I am not even sure how to explain it properly. :)

I have code that creates a childwindow. I then want a canvas on the childwindow so I can draw lots of sprite, SFtexts etc.
Now when I reach part of the code that has a childwindow with a canvas (which is virtually all my childwindows), the screen blinks for a split second. It is hard to describe but it looks like the gamewindow is cleared or refreshed or that I quickly pressed alt-tab really quickly (which I did not). As my game relies on lots of childwindows opening and closing frequently then this makes the game all but unplayable.
Note it only seems to happen when in fullscreen mode.

Now when I comment out the line that creates a canvas, the blinking/refreshing does not happen.

First see the code where I call the childwindow and canvas in one of my menu methods. If I comment out the //initSubMenuCanvas method in this function then the blinking does not happen. (obviously I have to comment out all of the lines that are drawing to that canvas as well).

Code (cpp) Select

void drawEngine::drawStartTurnSummarySubMenu(Nation *passed_Nation)
{
sf::Vector2i pos(gameWindow.getSize().x * 0.1, gameWindow.getSize().y * 0);
sf::Vector2i size((gameWindow.getSize().x - (gameWindow.getSize().x * 0.25)), getLowerScreenPos().y);

setupChildWindow(pos, size, "Start Turn Summary", sf::Color::Red, battleChildWin);

tgui::Container::Ptr container = gui.get<tgui::Container>(battleChildWin);
        initSubMenuCanvas(container);
.....
.....
//lots of draw sprites or sf texts onto the canvas throughout the rest of this method.




So you can see below the functions where I actually create the childwindow and canvas. In the initSubMenuCanvas I have tried removing everything except the setupCanvas call but it makes not difference. I had wanted to provide a full working example but the code is quite long and complex now.

Code (cpp) Select


bool drawEngine::setupChildWindow(sf::Vector2i pos, sf::Vector2i size, string title_text, sf::Color titleText_Color, string passed_childName)
{
if (gui.get(passed_childName) == NULL)
{
tgui::ChildWindow::Ptr childWin = theme->load("ChildWindow");
childWin->setPosition(pos.x, pos.y);
childWin->setSize(size.x, size.y);
childWin->getRenderer()->setTitleColor(titleText_Color);
childWin->setTitle(title_text);
gui.add(childWin, passed_childName);
cout << "creating win " << passed_childName << "\n";
return true;
}

return false;
}

void drawEngine::initSubMenuCanvas(tgui::Container::Ptr container)
{
sf::Sprite subMenuBackGroundSprite(subMenuBackGround);
float childSizeX = container->getSize().x;
float childSizeY = container->getSize().y;
sf::Vector2f scaledValues;

sf::Vector2i pos;
sf::Vector2i size(childSizeX, childSizeY);;

if (setupCanvas(pos, size, "subMenuCanvas", container))
{
scaledValues = calcScale(childSizeX, childSizeY, subMenuBackGround.getSize());
subMenuBackGroundSprite.setScale(scaledValues.x, scaledValues.y);

tgui::Canvas::Ptr canvas = container->get<tgui::Canvas>("subMenuCanvas");
canvas->draw(subMenuBackGroundSprite);
}
}

bool drawEngine::setupCanvas(sf::Vector2i pos, sf::Vector2i size, string passed_canvasName, tgui::Container::Ptr container)
{
if ((container != NULL && container->get(passed_canvasName) == NULL) || (container == NULL && gui.get(passed_canvasName) == NULL))
{
auto canvas = std::make_shared<tgui::Canvas>();
canvas->setPosition(pos.x, pos.y);
canvas->setSize(size.x, size.y);

if (container == NULL)
{
gui.add(canvas, passed_canvasName);
}
else
{
container->add(canvas, passed_canvasName);
}

return true;
}

return false;
}

#22
Help requests / listbox text color
20 October 2015, 02:41:19
Is there a way to have different text color for different items in he same listbox?

I've various strings and I want to color code them differently depending on certain criteria. Now I can get see in the listbox renderer a text color method but it seems to be for all text and not specific to a certain item. Is there a way to do that?
#23
Right again Texus, I thought I was adding the second parameter in the addItem but nope I was not. Thanks again.
#24
So I have visual studio 2013 express so according to the signal tutorial, I need to use the connectEX method.

So when an item is selected in a listbox, is there a way to get the itemID in the callback? I have the below simple signal function but the itemID is always empty.

Code (cpp) Select


void drawEngine::armyUnitListBoxSignalFunction(const tgui::Callback& callback)
{
string item = callback.text;
string itemID = callback.itemId;
}



it is called using the below call

Code (cpp) Select

        tgui::ListBox::Ptr armyUnitListBox = gui.get<tgui::ListBox>(ListBoxID, true);
armyUnitListBox->connectEx("ItemSelected", &drawEngine::armyUnitListBoxSignalFunction, this);
#25
arrrggh you are 100% correct (as usual).

This line

Code (cpp) Select


tgui::ListBox::Ptr regionListBox = testClass.gui.get<tgui::ListBox>(listboxID);



But my listbox was added into the canvas which is in turn was in a childwindow.

Doing this works

Code (cpp) Select

tgui::ListBox::Ptr regionListBox = testClass.gui.get<tgui::ListBox>(listboxID, true);


Thanks again