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

#91
Hi,

Sorry for the delay in replying. I'm not sure of the best way to show you the callstack? See the below screenshot but I'm guessing you want more info or for me to click on one of them? If so which one? The below is the error I got with chatbox->addLine from the full example v0.6 code. I seem to get this error when using textbox->addtext or settext And it happens with chatbox->addline.





I've used the example v0.6 full code and I get the same error with chatbox->addline. See below, I added a small textbox section, however as mentioned I get the same error with chatbox as well.

Code (cpp) Select


#define THEME_CONFIG_FILE "C:/Users/mcgoldrickb/Documents/TGUI-0.6/widgets/Black.conf"
#include <TGUI/TGUI.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI window");
    tgui::Gui gui(window);

    if (gui.setGlobalFont("C:/Users/mcgoldrickb/Documents/TGUI-0.6/fonts/DejaVuSans.ttf") == false)
        return 1;

    tgui::Picture::Ptr picture(gui);
    picture->load("C:/Users/mcgoldrickb/Documents/TGUI-0.6/examples/Linux.jpg");

    tgui::Button::Ptr button(gui);
    button->load(THEME_CONFIG_FILE);
    button->setPosition(40, 25);
    button->setText("Quit");
    button->setCallbackId(1);
    button->bindCallback(tgui::Button::LeftMouseClicked);
    button->setSize(300, 40);

tgui::TextBox::Ptr textbox(gui);
textbox->load(THEME_CONFIG_FILE);
textbox->setSize(200, 100);
    textbox->setTextSize(20);
    textbox->setPosition(600, 25);
textbox->addText("Hello");

    tgui::ChatBox::Ptr chatbox(gui);
    chatbox->load(THEME_CONFIG_FILE);
    chatbox->setSize(200, 100);
    chatbox->setTextSize(20);
    chatbox->setPosition(400, 25);
    chatbox->addLine("Line 1", sf::Color::Red);
    chatbox->addLine("Line 2", sf::Color::Blue);
    chatbox->addLine("Line 3", sf::Color::Green);
    chatbox->addLine("Line 4", sf::Color::Yellow);
    chatbox->addLine("Line 5", sf::Color::Cyan);
    chatbox->addLine("Line 6", sf::Color::Magenta);

    tgui::Checkbox::Ptr checkbox(gui);
    checkbox->load(THEME_CONFIG_FILE);
    checkbox->setPosition(40, 80);
    checkbox->setText("Checkbox");
    checkbox->setSize(32, 32);

    tgui::ChildWindow::Ptr child(gui);
    child->load(THEME_CONFIG_FILE);
    child->setSize(200, 100);
    child->setBackgroundColor(sf::Color(80, 80, 80));
    child->setPosition(400, 460);
    child->setTitle("Child window");
    child->setIcon("C:/Users/mcgoldrickb/Documents/TGUI-0.6/examples/icon.jpg");

    tgui::ComboBox::Ptr comboBox(gui);
    comboBox->load(THEME_CONFIG_FILE);
    comboBox->setSize(120, 21);
    comboBox->setPosition(210, 440);
    comboBox->addItem("Item 1");
    comboBox->addItem("Item 2");
    comboBox->addItem("Item 3");
    comboBox->setSelectedItem("Item 2");

    tgui::EditBox::Ptr editBox(gui);
    editBox->load(THEME_CONFIG_FILE);
    editBox->setPosition(40, 200);
    editBox->setSize(300, 30);

    tgui::Label::Ptr label(gui);
    label->load(THEME_CONFIG_FILE);
    label->setText("Label");
    label->setPosition(40, 160);
    label->setTextColor(sf::Color(200, 200, 200));
    label->setTextSize(24);

    tgui::ListBox::Ptr listBox(gui);
    listBox->load(THEME_CONFIG_FILE);
    listBox->setSize(150, 120);
    listBox->setItemHeight(20);
    listBox->setPosition(40, 440);
    listBox->addItem("Item 1");
    listBox->addItem("Item 2");
    listBox->addItem("Item 3");

    tgui::LoadingBar::Ptr loadingbar(gui);
    loadingbar->load(THEME_CONFIG_FILE);
    loadingbar->setPosition(40, 330);
    loadingbar->setSize(300, 30);
    loadingbar->setValue(35);

    tgui::MenuBar::Ptr menu(gui);
    menu->load(THEME_CONFIG_FILE);
    menu->setSize(window.getSize().x, 20);
    menu->addMenu("File");
    menu->addMenuItem("File", "Load");
    menu->addMenuItem("File", "Save");
    menu->addMenuItem("File", "Exit");
    menu->bindCallback(tgui::MenuBar::MenuItemClicked);
    menu->setCallbackId(2);

    sf::Texture texture;
    texture.loadFromFile("C:/Users/mcgoldrickb/Documents/TGUI-0.6/examples/ThinkLinux.jpg");

    tgui::Panel::Ptr panel(gui);
    panel->setSize(200, 140);
    panel->setPosition(400, 150);
    panel->setBackgroundTexture(&texture);

    tgui::RadioButton::Ptr radioButton(gui);
    radioButton->load(THEME_CONFIG_FILE);
    radioButton->setPosition(40, 120);
    radioButton->setText("Radio Button");
    radioButton->setSize(32, 32);

    tgui::Slider::Ptr slider(gui);
    slider->load(THEME_CONFIG_FILE);
    slider->setVerticalScroll(false);
    slider->setPosition(40, 250);
    slider->setSize(300, 25);
    slider->setValue(2);

    tgui::Scrollbar::Ptr scrollbar(gui);
    scrollbar->load(THEME_CONFIG_FILE);
    scrollbar->setVerticalScroll(false);
    scrollbar->setPosition(40, 290);
    scrollbar->setSize(300, 25);
    scrollbar->setMaximum(5);
    scrollbar->setLowValue(3);

    tgui::Slider2d::Ptr slider2d(gui);
    slider2d->load("C:/Users/mcgoldrickb/Documents/TGUI-0.6/widgets/Slider2d/Black.conf");
    slider2d->setPosition(400, 300);
    slider2d->setSize(200, 150);

    tgui::SpinButton::Ptr spinButton(gui);
    spinButton->load(THEME_CONFIG_FILE);
    spinButton->setPosition(40, 410);
    spinButton->setVerticalScroll(false);
    spinButton->setSize(40, 20);

    tgui::SpriteSheet::Ptr spritesheet(gui);
    spritesheet->load("C:/Users/mcgoldrickb/Documents/TGUI-0.6/examples/ThinkLinux.jpg");
    spritesheet->setCells(4, 4);
    spritesheet->setVisibleCell(2, 3);
    spritesheet->setSize(160, 120);
    spritesheet->setPosition(620, 25);

    tgui::Tab::Ptr tab(gui);
    tab->load(THEME_CONFIG_FILE);
    tab->setPosition(40, 370);
    tab->add("Item 1");
    tab->add("Item 2");
    tab->add("Item 3");

    tgui::TextBox::Ptr textBox(gui);
    textBox->load(THEME_CONFIG_FILE);
    textBox->setPosition(210, 470);
    textBox->setSize(180, 120);
    textBox->setTextSize(16);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            gui.handleEvent(event);
        }

        tgui::Callback callback;
        while (gui.pollCallback(callback))
        {
            if (callback.id == 1)
                window.close();

            else if (callback.id == 2)
            {
                if (callback.text == "Exit")
                    window.close();
            }
        }

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

    return 0;
}

#92
Help requests / Error when adding text to textBox
22 January 2015, 09:27:00
Hey Folks,

So I'm trying to use textBox where I display some game data in an efficient way with scoll-bars. However I get an error when using the setText or addText methods. (using v0.6 btw)

Code (cpp) Select


tgui::TextBox::Ptr textBoxList;

textBoxList->load(themeConfFile);
textBoxList->setPosition(20, 20);
textBoxList->setSize(600, 300);
textBoxList->setBackgroundColor(sf::Color::White);
textBoxList->setSize(600, 300);
textBoxList->setText("Nation\t");



I get an run error with visual studio.



When I press retry, it breakpoints into dbgheap.c at line 1424.

Also I had another question about textbox and chatbox. Is there a way to automatically scroll down the textbox, i.e. if the amount of text exceeds the ysize, then can I move the scroll automatically so the last entry is the one that stays in focus within the textbox?
#93
Help requests / Re: views in TGUI
18 January 2015, 05:06:35
Thank you so much for the detailed and helpful reply Texus - much appreciated. Also this is a great set of libraries - I wish I had found this when I first started doing SFML.

I think panels might be the way forward, although I'll still retain one main View for actual game content that I've already written. I'll just have 2 panels that are currently doing the right and lower views currently. There sole purpose is to display game stats and get user input so that should actually work out ok.
#94
Help requests / Menu hot-keys
18 January 2015, 04:05:36
So is there a way to have multiple call-backs be defined to the same call-backID?

i.e. so I define an ENUM like below for each call-back event

Code (cpp) Select


enum GUICallBackID {
QUIT_GAME,
NEW_GAME,
LOAD_GAME,
SAVE_GAME,
EXIT_GAME,
NEXT,
};



Now I define radio buttons for each of these menu options, with the mouse clicked event bound to each id. for example, this is the quit menu callback ID.
(RadioButtonList is vector containing each radio button.)

Code (cpp) Select

RadioButtonList[i]->setCallbackId(QUIT_GAME);
RadioButtonList[i]->bindCallback(tgui::Button::LeftMouseClicked);


However what I also want to do is for the QUIT_GAME callbackID to be trigger if the user presses a hot-key, like say Q or 0 for menu option 0. Is there a way to do this? I tried adding a second bindCallback function but that obviously simply overwrote the left mouse clicked event.

Many thanks in advance.
#95
Help requests / Re: views in TGUI
17 January 2015, 07:47:04
or better still. Is there a way for tgui widgets etc to be drawn in specific SFML views? i.e. if the widgets position is outside the view, then it doesn't appear on the screen or overlap onto other views?

I've tried something like the below where i set the window view, add some widgets and the call the gui->draw method. However the widgets don't seem to be drawn within the view. Instead they go onto the other views where i want them to actually go screen if they are not drawn within the view size.

Code (cpp) Select


     window.setView(mainView);

     tgui::RadioButton::Ptr radioButton1(gui);
     tgui::RadioButton::Ptr radioButton2(gui);
     tgui::RadioButton::Ptr radioButton3(gui);


    radioButton1->load(themeConfFile);
    radioButton1->setPosition(20, 20);
    radioButton1->setText("Quit Game");
    radioButton1->setSize(20, 20);
 

    radioButton2->load(themeConfFile);
    radioButton2->setPosition(20, 60);
    radioButton2->setText("Start New Game");
    radioButton2->setSize(20, 20);

    radioButton3->load(themeConfFile);
    radioButton3->setPosition(20, 100);
    radioButton3->setText("Load Old Game");
    radioButton3->setSize(20, 20);

     gui.draw();

#96
Help requests / views in TGUI
17 January 2015, 07:36:48
Hey Folks,

I'm still new to programming in general and new to SFML. I've just installed TGUI and I'm trying to provide user input with a more professional feel than what I've been previous doing.

With SFML, I setup 3 views.
1 mainView where the game action happens.
1 lowerView which updates with stats info as the game progress
1 rightView which has some static data.

What I'd like to do with TGUI is to have 3 seperate views like above. I want to be able to display all of my game images in the mainView. however I want the option to have a menu bar within this mainview.

From what I see the tgui::Gui gui; doesn't have any views. So is there a way to create 3 seperate windows? With the main window I want to draw images that only appear within this window, i.e. if the image overlaps the mainview size, then it should not appear in right or lower views.

I see there is a child window but I don't want the user to be able to close any of those child windows - is there a way to remove close X button in a child window? Do child window's fufill the same function in tgui as view did in SFML? i.e. the ability to split up the window into multiple screens.