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.


Messages - starkhorn

Pages: 1 2 [3] 4 5 ... 7
31
Help requests / v0.7 add horizontal ListBox
« on: 21 September 2015, 03:24:48 »
Hi Texus,

Is it possible to add a horizontal scrollbar to a listbox? I have some string items that are too long to display on a single line and I would like users to be able to scroll horizontally so they are see the end of each line.

Or is there a way to display a single item over multiple lines?


32
Help requests / Re: v0.7 listbox auto scrolling
« on: 17 September 2015, 00:03:05 »
No worries at all and thanks for the help once again.

But I'll add a setAutoScroll function in v0.7-alpha2, I'll probably even make it scroll by default so that you don't even have to call anything.

Yeah this would be a great idea - perhaps with a method to disable auto-scrolling as well?

33
Help requests / Re: v0.7 listbox auto scrolling
« on: 14 September 2015, 01:17:11 »
Hey Texus,

Just wondering if you had a chance to look at this question ? I know you are busy so no worries if you need more time etc.

34
Help requests / v0.7 listbox auto scrolling
« on: 12 September 2015, 04:00:03 »
Hi Texus,

In a chatbox, when I add a new line, if it is larger than the size of the chatbox, it automatically scrolls down.
However in a listbox, I do not get the same behaviour when I add a new item. I get the scrollbar fine and I can manually scroll up and down which is great.
Basically I want to use the listbox functionality of being able to select each line and call functions when a particular line is clicked. However I also want the chatbox functionality of autoscrolling when a new item is added.

Is there any flag on a listbox to enable this same behaviour?

35
Help requests / v0.7 listbox textsize
« on: 12 September 2015, 03:06:38 »
Hi Texus,

I cannot seem to locate a setTextSize method for a listbox - (i.e. chatbox has such a method so I was looking for something similiar).

I see there is a setItemHeight method but in the documents is says "This size is always a little big greater than the text size."

So is this what actually determines the text size in a listbox?

36
Help requests / Re: v0.7 widget.conf syntax
« on: 08 September 2015, 01:17:52 »
Ok thanks. I'm at work now (based in New Zealand) so I'll try that when I get home.

To confirm the below

I is supposed to be:
Code: (cpp) [Select]
tgui::Button::Ptr button = theme->load("CustomButtonRomeHI");
without the "Button." in front of it. But I still don't get how you could get an exception WidgetConverer. That object is only created once the button was fully loaded.

Ok so in the main example, indeed it worked when I dropped the preceding "Button.".
Then I went back to my class but still got same error.
After a bit more tinkering, I realized that I had only updated the Button.CustomButtonRomeHI section with the Part(56,  0,  48, 64);

All of the others were as below. So the CustomButtonRomeHI got created fine, but none of the others. Obviously Part is mandatory now then. :)

Code: (cpp) [Select]
Button.CustomButtonRomeLI {
    NormalImage  : "..\images\icons\romeNationIcon_v3.png" (  104,  0,  48, 64);
    HoverImage   : "..\images\icons\romeNationIcon_v3.png" (  104,  65,  48, 64);
    DownImage    : "..\images\icons\romeNationIcon_v3.png" (  104,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

For how I got an exception in WidgetConverer then I'm not sure. I will put back my original file and re-test when I get the pdb file. Likely tonight (your tomorrow) though.

Thanks for all of your help and sorry for all of the questions with v0.7! :)

37
Help requests / Re: v0.7 widget.conf syntax
« on: 08 September 2015, 00:48:01 »
Thanks. I downloaded the pre-compiled file TGUI-0.7-alpha1 Visual C++12 (2013) - 32bit.zip

38
Help requests / Re: v0.7 widget.conf syntax
« on: 08 September 2015, 00:41:26 »
Do you know how/where I can get a tgui-d.pdb? I can try to debug further but now I keep getting tgui-d.pdb not loaded.....unsure how it was working earlier.

39
Help requests / Re: v0.7 widget.conf syntax
« on: 08 September 2015, 00:20:47 »
Also I tried using the Black.png as well but no joy

i.e.

Code: (cpp) [Select]
Button.CustomButtonRomeHI {
    NormalImage  : "Black.png" Part(  56,  0,  48, 64);
    HoverImage   : "Black.png" Part(  56,  65,  48, 64);
    DownImage    : "Black.png" Part(  56,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}


I also tried coping the entire Button section into the new section as well but same thing.

i.e. this is the exact same as the Button section which works.

Code: (cpp) [Select]
Button.CustomButtonRomeHI {
    NormalImage     : "Black.png" Part( 0, 64, 45, 50) Middle(10, 0, 25, 50);
    HoverImage      : "Black.png" Part(45, 64, 45, 50) Middle(10, 0, 25, 50);
    DownImage       : "Black.png" Part(90, 64, 45, 50) Middle(10, 0, 25, 50);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

40
Help requests / Re: v0.7 widget.conf syntax
« on: 08 September 2015, 00:17:18 »
Hi Texus,

Ok I tried the below which is pretty much as per one of tutorials and example codes.

Here is my new widget config file - rest of the txt file is unchanged and i did not change the Button section at all. I thought maybe it couldn't find the png as it was in a different folder, so I copied it into the same folder as the rome.txt file and removed the ..\..\ lines but same thing.

Note when I change to just below then it works fine

Code: (cpp) [Select]
tgui::Button::Ptr button = theme->load("Button");


Code: (cpp) [Select]
Button {
    NormalImage     : "Black.png" Part( 0, 64, 45, 50) Middle(10, 0, 25, 50);
    HoverImage      : "Black.png" Part(45, 64, 45, 50) Middle(10, 0, 25, 50);
    DownImage       : "Black.png" Part(90, 64, 45, 50) Middle(10, 0, 25, 50);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

Button.CustomButtonRomeAR {
    NormalImage  : "romeNationIcon_v2.png" Part(  248,  0,  48, 64);
    HoverImage   : "romeNationIcon_v2.png" Part(  248,  65,  48, 64);
    DownImage    : "romeNationIcon_v2.png" Part(  248,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

Button.CustomButtonRomeCMD {
    NormalImage  : "romeNationIcon_v2.png" Part(  296,  0,  48, 64);
    HoverImage   : "romeNationIcon_v2.png" Part(  296,  65,  48, 64);
    DownImage    : "romeNationIcon_v2.png" Part(  296,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

Button.CustomButtonRomeHC {
    NormalImage  : "romeNationIcon_v2.png" Part(  152,  0,  48, 64);
    HoverImage   : "romeNationIcon_v2.png" Part(  152,  65,  48, 64);
    DownImage    : "romeNationIcon_v2.png" Part(  152,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

Button.CustomButtonRomeHI {
    NormalImage  : "romeNationIcon_v2.png" Part(  56,  0,  48, 64);
    HoverImage   : "romeNationIcon_v2.png" Part(  56,  65,  48, 64);
    DownImage    : "romeNationIcon_v2.png" Part(  56,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

Button.CustomButtonRomeLC {
    NormalImage  : "romeNationIcon_v2.png" Part(  200,  0,  48, 64);
    HoverImage   : "romeNationIcon_v2.png" Part(  200,  65,  48, 64);
    DownImage    : "romeNationIcon_v2.png" Part(  200,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

Button.CustomButtonRomeLI {
    NormalImage  : "romeNationIcon_v2.png" Part(  104,  0,  48, 64);
    HoverImage   : "romeNationIcon_v2.png" Part(  104,  65,  48, 64);
    DownImage    : "romeNationIcon_v2.png" Part(  104,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}



Code: (cpp) [Select]

#include <TGUI/TGUI.hpp>
#include <string>
#include <math.h>
#define THEME_CONFIG_FILE "C:\\programming\\Debug\\widgets\\rome.txt"
using namespace std;

void buttonFunction()
{
std::cout << "Button pressed" << std::endl;
}


void loadWidgets(tgui::Gui& gui)
{
// Load the black theme
tgui::Theme::Ptr theme = std::make_shared<tgui::Theme>(THEME_CONFIG_FILE);


// Create the login button
tgui::Button::Ptr button = theme->load("Button.CustomButtonRomeHI");
button->setSize(100, 40);
button->setPosition(50, 50);
button->setText("Test");
button->connect("pressed", buttonFunction);
gui.add(button);

// Call the login function when the button is pressed

}

int main()
{
sf::RenderWindow gameWindow;
sf::VideoMode desktop;
sf::Event event;
tgui::Gui gui;

desktop = sf::VideoMode::getDesktopMode();
gameWindow.create(sf::VideoMode(desktop.width, desktop.height, desktop.bitsPerPixel), "Test");
gameWindow.setPosition(sf::Vector2i(0, 0));
gui.setWindow(gameWindow);
gui.setGlobalFont("C:\\programming\\Debug\\inputfiles\\fonts\\DejaVuSans.ttf");

loadWidgets(gui);


// Main loop
while (gameWindow.isOpen())
{

while (gameWindow.pollEvent(event))
{
// When the window is closed, the application ends
if (event.type == sf::Event::Closed)
gameWindow.close();


// Pass the event to all the widgets
gui.handleEvent(event);
}

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

return 0;
}


41
Help requests / Re: v0.7 widget.conf syntax
« on: 07 September 2015, 22:17:48 »
Ok I changed my section to Button.CustomButtonRomeHI in the text file. I then ensure that passed_themeSection is as below.

Code: (cpp) [Select]
passed_themeSection "Button.CustomButtonRomeHI"

however I still get same error. I notice the Button section has a Part and Middle, whereas I did not have that. So I also tried the below but same result

Code: (cpp) [Select]
Button.CustomButtonRomeHI {
    NormalImage  : "../../images/icons/romeNationIcon_v2.png" Part(  56,  0,  48, 64);
    HoverImage   : "../../images/icons/romeNationIcon_v2.png" Part(  56,  65,  48, 64);
    DownImage    : "../../images/icons/romeNationIcon_v2.png" Part(  56,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

42
Help requests / v0.7 widget.conf syntax
« on: 07 September 2015, 09:28:46 »
Sorry for all of the v0.7 questions lately - I really do appreciate your help.

In v0.69 I had a button conf like below

Code: (cpp) [Select]

Button:
    NormalImage  = "../../images/icons/romeNationIcon_v2.png" (  56,  0,  48, 64)
    HoverImage   = "../../images/icons/romeNationIcon_v2.png" (  56,  65,  48, 64)
    DownImage    = "../../images/icons/romeNationIcon_v2.png" (  56,  129,  48, 64)
   
    TextColor          = (200, 200, 200)
    SeparateHoverImage = true

So in v0.7, I created a new section as below

Code: (cpp) [Select]

CustomButtonRomeAR {
    NormalImage  : "../../images/icons/romeNationIcon_v2.png" (  248,  0,  48, 64);
    HoverImage   : "../../images/icons/romeNationIcon_v2.png" (  248,  65,  48, 64);
    DownImage    : "../../images/icons/romeNationIcon_v2.png" (  248,  129,  48, 64);
    TextColorNormal : rgb(190, 190, 190);
    TextColorHover  : rgb(250, 250, 250);
    TextColorDown   : rgb(250, 250, 250);
}

however whenever I try to create a button with this section, it throws an error

Code: (cpp) [Select]
tgui::Button::Ptr button = theme->load(passed_themeSection);

where passed_themeSection = "CustomButtonRomeHI"

I am assuming I've gotten the syntax incorrect here?

Sorry error is:

"tgui::Exception at memory location 0x0014CF08."

It breaks into WidgetConverter.hpp at line 65

Code: (cpp) [Select]

      /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// @brief Cast the widget to the required type
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        template <class T>
        operator std::shared_ptr<T>()
        {
            std::shared_ptr<T> result = std::dynamic_pointer_cast<T>(m_widget);

            if (result == nullptr)
                throw Exception{"Value returned by Theme::load must match type of variable!"};

            return result;
        }


43
Help requests / Re: v0.7 error when trying to add radio button
« on: 06 September 2015, 00:43:53 »
sorry - yeah I was using the Visual C++ 11 (2012) - 32-bit sfml 2.3.1 dll files and not the Visual C++ 12 (2013) - 32-bit files.

Thanks again.

44
Help requests / v0.7 error when trying to add radio button
« on: 05 September 2015, 23:44:26 »
So I am trying to add radio buttons using the black.txt file.
I've setup the theme as per the themes tutorial. (https://tgui.eu/tutorials/v0.7/using-themes/)

I have been able to create panels and labels without issue, but the radiobutton throws an error. I am using visual studio 2013 and I don't have a tgui.pdb so when it fails, I don't see the exact source line it fails. I get a Expression: pFirstBlock ==pHead error in the dbgheap.c.

My function is below and it fails at the "tgui::RadioButton::Ptr radioButton = theme->load("RadioButton");" line.

Code: (cpp) [Select]
void Test::setupRadioButton(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_colour, vector<string> stringList, tgui::Container::Ptr container)
{
int yposIncrementer = 0;

for (int i = 0; i < stringList.size(); i++)
{
if (container != NULL && container->get(stringList[i]) == NULL)
{
tgui::RadioButton::Ptr radioButton = theme->load("RadioButton");
radioButton->setPosition(pos.x, pos.y + yposIncrementer);
radioButton->setSize(size.x, size.y);
radioButton->getRenderer()->setTextColor(passed_colour);
if (stringList.size() > 0)
{
radioButton->setText(stringList[i]);
}
container->add(radioButton, stringList[i]);
yposIncrementer += size.y;
}
}
}

Here is a full working example. The drawLoadingScreen method which uses a panel with labels works fine. However the drawMainMenu fails when I try to add a radiobutton. Am I doing something wrong here?

Code: (cpp) [Select]
#include <TGUI/TGUI.hpp>
#include <string>
#include <math.h>
#define THEME_CONFIG_FILE "C:\\Programming\\Debug\\widgets\\Black.txt"

using namespace std;

class Test
{
public:

Test();

sf::RenderWindow gameWindow;
sf::VideoMode desktop;
sf::Event event;
tgui::Callback callback;
tgui::Gui gui;
sf::Texture mainMenuBackGround;

tgui::Theme::Ptr theme;
tgui::Layout windowWidth;
tgui::Layout windowHeight;
string mainPanelName;

void setThemeConfigFile(string passed_filename);
void initBackGroundTextures();
void initMainMenuPanel(sf::Vector2i pos, sf::Vector2i size);
void setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture = NULL);
void setupLabel(sf::Vector2i pos, int passed_TextSize, sf::Color passed_colour, string labelText, tgui::Container::Ptr container = NULL);
void setupRadioButton(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_colour, vector<string> stringList, tgui::Container::Ptr container = NULL);
bool drawLoadingScreenGUI();
bool drawMainMenuGUI(bool mainMenu); //main menu
};

Test::Test()
{
desktop = sf::VideoMode::getDesktopMode();
gameWindow.create(sf::VideoMode(desktop.width, desktop.height, desktop.bitsPerPixel), "Test");
gameWindow.setPosition(sf::Vector2i(0, 0));
gui.setWindow(gameWindow);
gui.setGlobalFont("C:\\Programming\\Debug\\inputfiles\\fonts\\DejaVuSans.ttf");
initBackGroundTextures();
setThemeConfigFile(THEME_CONFIG_FILE);
mainPanelName = "mainPanel";
}

void Test::setThemeConfigFile(string passed_filename)
{
// Load the black theme
theme = std::make_shared<tgui::Theme>(passed_filename);

// Get a bound version of the window size
// Passing this to setPosition or setSize will make the widget automatically update when the view of the gui changes
windowWidth = tgui::bindWidth(gui);
windowHeight = tgui::bindHeight(gui);
}

void Test::initBackGroundTextures()
{
if (!mainMenuBackGround.loadFromFile("C:\\Users\\mcgoldrickb\\Documents\\Visual Studio 2013\\Projects\\rome_vs2013\\Debug\\images\\loading_screen.png"))
{
std::cout << "Failed to load mainMenuBackGround image!" << std::endl;
}
}

void Test::initMainMenuPanel(sf::Vector2i pos, sf::Vector2i size)
{
setupPanel(pos, size, sf::Color::Black, mainPanelName, &mainMenuBackGround);
}

void Test::setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture)
{

if (gui.get(passed_panelName) == NULL)
{
auto mainMenuPanel = std::make_shared<tgui::Panel>();
mainMenuPanel->setPosition(pos.x, pos.y);
mainMenuPanel->setSize(size.x, size.y);
mainMenuPanel->setBackgroundColor(passed_backGroundColour);
if (passed_texture != NULL)
{
mainMenuPanel->add(std::make_shared<tgui::Picture>(*passed_texture));
//mainMenuPanel->getRenderer()->setBackgroundTexture(passed_texture);
}
gui.add(mainMenuPanel, passed_panelName);
}
}

void Test::setupLabel(sf::Vector2i pos, int passed_TextSize, sf::Color passed_colour, string labelText, tgui::Container::Ptr container)
{
if (container->get(labelText) == NULL)
{
tgui::Label::Ptr label = theme->load("Label");
container->add(label, labelText);
label->setPosition(pos.x, pos.y);
label->setTextSize(passed_TextSize);
label->setTextColor(passed_colour);
label->setText(labelText);
}
}

void Test::setupRadioButton(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_colour, vector<string> stringList, tgui::Container::Ptr container)
{
int yposIncrementer = 0;

for (int i = 0; i < stringList.size(); i++)
{
if (container != NULL && container->get(stringList[i]) == NULL)
{
tgui::RadioButton::Ptr radioButton = theme->load("RadioButton");
radioButton->setPosition(pos.x, pos.y + yposIncrementer);
radioButton->setSize(size.x, size.y);
radioButton->getRenderer()->setTextColor(passed_colour);
if (stringList.size() > 0)
{
radioButton->setText(stringList[i]);
}
container->add(radioButton, stringList[i]);
yposIncrementer += size.y;
}
}
}

bool Test::drawLoadingScreenGUI()
{
sf::Vector2i pos, size((gameWindow.getSize().x), (gameWindow.getSize().y));
initMainMenuPanel(pos, size);

//Setup LoadingScreen Label
setupLabel(pos, 100, sf::Color::Red, "Roman Empire", gui.get<tgui::Container>(mainPanelName));


//This is the main menu instructions Label
pos.x = 25;
pos.y = gui.get(mainPanelName)->getSize().y - 100;
setupLabel(pos, 50, sf::Color::Red, "Loading game...", gui.get<tgui::Container>(mainPanelName));


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

return true;
}

bool Test::drawMainMenuGUI(bool mainMenu)
{
vector<string> widgetStrList;

//Initialize the main menu panel
sf::Vector2i pos, size((gameWindow.getSize().x), (gameWindow.getSize().y));
setupPanel(pos, size, sf::Color::Black, mainPanelName, &mainMenuBackGround);
sf::Vector2i panelSize(gui.get(mainPanelName)->getSize().x, gui.get(mainPanelName)->getSize().y);


//This is the main menu Title
pos.x = 25;
pos.y = 50;
setupLabel(pos, 100, sf::Color::Red, "Roman Empire - Main Menu", gui.get<tgui::Container>(mainPanelName));



//Setup Main Menu Radio Buttons
pos.y = 50 + 70;
size.x = 35;
size.y = 35;

widgetStrList.push_back("\tQuit Game");
widgetStrList.push_back("\tStart New Game");
widgetStrList.push_back("\tLoad Old Game");

if (mainMenu == true)
{
setupRadioButton(pos, size, sf::Color::Red, widgetStrList, gui.get<tgui::Container>(mainPanelName));
}
else if (mainMenu == false)
{
widgetStrList.push_back("\tSave Current Game");
widgetStrList.push_back("\tExit Main Menu");
setupRadioButton(pos, size, sf::Color::Red, widgetStrList, gui.get<tgui::Container>(mainPanelName));
}

widgetStrList.clear();

gameWindow.clear();

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


45
awesome - thank you. Worked a treat.

Pages: 1 2 [3] 4 5 ... 7