Main Menu
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 - Charsmud

#1
Installation help / Re: Compiling TGUI with VS2015
25 September 2015, 03:07:09
Yep, I am using the files from the .zip. My Button.hpp looks like this:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// Copyright (C) 2012-2013 Bruno Van de Velde (vdv_b@tgui.eu)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
//    you must not claim that you wrote the original software.
//    If you use this software in a product, an acknowledgment
//    in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
//    and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#ifndef TGUI_BUTTON_HPP
#define TGUI_BUTTON_HPP


#include <TGUI/ClickableWidget.hpp>

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace tgui
{
    class Container;

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    class TGUI_API Button : public ClickableWidget
    {
      public:

        typedef SharedWidgetPtr<Button> Ptr;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Default constructor
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Button();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Copy constructor
        ///
        /// \param copy  Instance to copy
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Button(const Button& copy);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Destructor
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual ~Button();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Overload of assignment operator
        ///
        /// \param right  Instance to assign
        ///
        /// \return Reference to itself
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Button& operator= (const Button& right);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // Makes a copy of the widget by calling the copy constructor.
        // This function calls new and if you use this function then you are responsible for calling delete.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual Button* clone();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Loads the widget.
        ///
        /// \param configFileFilename  Filename of the config file.
        ///
        /// The config file must contain a Button section with the needed information.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        bool load(const std::string& configFileFilename);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the filename of the config file that was used to load the widget.
        ///
        /// \return Filename of loaded config file.
        ///         Empty string when no config file was loaded yet.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        const std::string& getLoadedConfigFile() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Set the position of the widget
        ///
        /// This function completely overwrites the previous position.
        /// See the move function to apply an offset based on the previous position instead.
        /// The default position of a transformable widget is (0, 0).
        ///
        /// \param x X coordinate of the new position
        /// \param y Y coordinate of the new position
        ///
        /// \see move, getPosition
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void setPosition(float x, float y);
        using Transformable::setPosition;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the size of the button.
        ///
        /// \param width   The new width of the button
        /// \param height  The new height of the button
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void setSize(float width, float height);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the caption of the button.
        ///
        /// \param text  New text to draw on top of the button.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setText(const sf::String& text);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the caption of the button.
        ///
        /// \return Text that is drawn on top of the button.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        sf::String getText() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the font of the text.
        ///
        /// When you don't call this function then the global font will be use.
        /// This global font can be changed with the setGlobalFont function from the parent.
        ///
        /// \param font  The new font
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setTextFont(const sf::Font& font);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the font of the text.
        ///
        /// \return  Pointer to the font that is currently being used
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        const sf::Font* getTextFont() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the color of the text.
        ///
        /// \param color  New text color
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setTextColor(const sf::Color& color);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the color of the text.
        ///
        /// \return The current text color
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        const sf::Color& getTextColor() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the character size of the text.
        ///
        /// \param size  The new text size.
        ///              If the size is set to 0 then the text will be auto-sized to fit inside the button.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setTextSize(unsigned int size);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the character size of the text.
        ///
        /// \return The current text size.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        unsigned int getTextSize() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the transparency of the widget.
        ///
        /// \param transparency  The transparency of the widget.
        ///                      0 is completely transparent, while 255 (default) means fully opaque.
        ///
        /// Note that this will only change the transparency of the images. The parts of the widgets that use a color will not
        /// be changed. You must change them yourself by setting the alpha channel of the color.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void setTransparency(unsigned char transparency);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void keyPressed(sf::Keyboard::Key key);

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void widgetFocused();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // This function is a (slow) way to set properties on the widget, no matter what type it is.
        // When the requested property doesn't exist in the widget then the functions will return false.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual bool setProperty(std::string property, const std::string& value);

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // This function is a (slow) way to get properties of the widget, no matter what type it is.
        // When the requested property doesn't exist in the widget then the functions will return false.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual bool getProperty(std::string property, std::string& value) const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // Returns a list of all properties that can be used in setProperty and getProperty.
        // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      protected:

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // This function is called when the widget is added to a container.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void initialize(Container *const container);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // Draws the widget on the render target.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      public:

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// Defines specific triggers to Button.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        enum ButtonCallbacks
        {
            SpaceKeyPressed      = ClickableWidgetCallbacksCount * 1,     ///< Space key was pressed
            ReturnKeyPressed     = ClickableWidgetCallbacksCount * 2,     ///< Return key was pressed
            AllButtonCallbacks   = ClickableWidgetCallbacksCount * 4 - 1, ///< All triggers defined in Button and its base classes
            ButtonCallbacksCount = ClickableWidgetCallbacksCount * 4
        };


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      protected:

        std::string m_LoadedConfigFile;

        Texture m_TextureNormal_L;
        Texture m_TextureHover_L;
        Texture m_TextureDown_L;
        Texture m_TextureFocused_L;

        Texture m_TextureNormal_M;
        Texture m_TextureHover_M;
        Texture m_TextureDown_M;
        Texture m_TextureFocused_M;

        Texture m_TextureNormal_R;
        Texture m_TextureHover_R;
        Texture m_TextureDown_R;
        Texture m_TextureFocused_R;

        // If this is true then the L, M and R images will be used.
        // If it is false then the button is just one big image that will be stored in the M image.
        bool m_SplitImage;

        // Is there a separate hover image, or is it a semi-transparent image that is drawn on top of the others?
        bool m_SeparateHoverImage;

        // The SFML text
        sf::Text m_Text;

        // This will store the size of the text ( 0 to auto size )
        unsigned int m_TextSize;


        friend class ChildWindow;
    };

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#endif // TGUI_BUTTON_HPP



#2
Installation help / Re: Compiling TGUI with VS2015
22 September 2015, 03:34:01
Hm, I seem to be getting errors in the TGUI header files, like

Error   C2238   unexpected token(s) preceding ';'   Byte   E:\OpenGL\include\TGUI\Button.hpp, Line   44

Any suggestions?  I can't seem to figure out why the actual library is erring. 
#3
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 23:07:35
Ah, makes sense, I derped.  I'll look around and see what I can figure out.
#4
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 23:04:03
Hm... I seem to get 269 errors when I try it with my project.  For example:

'load': is not a member of 'tgui::Picture'


but it has methods like askToolTip, so I'm not sure what's going on.  the code worked previously, but I'm not sure what's throwing it off now. 
#5
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 21:47:27
Thank you very much for your help!
#6
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 19:16:23
Thanks so much!  Yeah, I have no idea why it's not working, because that is how the microsoft website says to set up a project for 64 bit.... 

https://www.dropbox.com/sh/fgs8zt7uq10afsg/AABfr7Ita1VGmAZ_W7mCqMiCa?dl=0
#7
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 18:56:34
I have x64 SFML and I used that to build TGUI, but I didn't see an option to change TGUI from 32 bit to 64 bit.  I went into Configuration Manager, tried with Win32, and it threw this error.  I changed the Active Solution Platform to a new one, Changed it from ARM to x64, set all the projects to x64, and it still throws the same error. 
#8
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 18:25:02
OK, it was able to be created with CMake.  However, now when I build in VS2015, I get the following:


Error   LNK1112   module machine type 'x64' conflicts with target machine type 'X86'   tgui   E:\Downloads\TGUI-0.7-alpha1\TGUI-0.7-alpha1\build\src\TGUI\sfml-graphics.lib(sfml-graphics-2.dll)

Any ideas?
#9
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 17:51:39
The file says 2.1 (Major version 2, minor 1).
#10
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 17:47:57
The path is "E:/OpenGL/include".  Inside that folder is a folder called SFML, and in that folder are all the SFML header and cpp files.
#11
Installation help / Compiling TGUI with VS2015
20 September 2015, 06:52:22
I am trying to compile TGUI for Visual Studio 2015 because the version I was using previously seemed to not work for VS2015.  However, I keep getting this error when I try to use CMAKE:

SFML found but version too low (requested: 2, found: 1.x.x)
CMake Error at CMakeLists.txt:290 (message):
  CMake couldn't find SFML.  Set the SFML_ROOT entry to SFML's root directory
  (containing "include" and "lib" directories).


Configuring incomplete, errors occurred!
See also "E:/Downloads/TGUI/CMakeFiles/CMakeOutput.log".


I am using SFML 2.3.2.
#12
I am using Visual Studio 2015.  I don't remember if I built or downloaded the library, but I've attached the dll to the post (https://www.dropbox.com/sh/5wg3bkmhtskx2av/AAD6rcFwKUJ4I9Bem-UdaHxQa?dl=0).  Here's the code block the line is in:

buttonExit->bindCallback(tgui::Button::LeftMouseClicked);
buttonExit->setCallbackId(1);
buttonApply->bindCallback(tgui::Button::LeftMouseClicked);
buttonApply->setCallbackId(3);
cbResolution->bindCallbackEx(resolutionCallback, tgui::ComboBox::ItemSelected);


and the associated code:

tgui::ComboBox::Ptr cbResolution(mGui);
cbResolution->load("Media/Widgets/Black.conf");
cbResolution->setSize(260, 30);
cbResolution->setPosition(360, 250);
cbResolution->addItem("800x600");
cbResolution->addItem("1024x768");
cbResolution->addItem("1280x800");
cbResolution->addItem("1280x1024");
cbResolution->addItem("1366x768");
cbResolution->addItem("1440x900");
cbResolution->addItem("1600x900");
cbResolution->addItem("1680x1050");
cbResolution->addItem("1920x1080");
#13
I recently updated my computer to windows 10, and have been getting the following error:

Severity Code Description Project File Line
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: void __thiscall tgui::CallbackManager::bindCallbackEx(class std::function<void __cdecl(struct tgui::Callback const &)>,unsigned int)" (__imp_?bindCallbackEx@CallbackManager@tgui@@QAEXV?$function@$$A6AXABUCallback@tgui@@@Z@std@@I@Z) referenced in function "public: virtual void __thiscall GuiOptions::loadWidgets(void)" (?loadWidgets@GuiOptions@@UAEXXZ) Byte E:\GameDev\C++\Byte\Byte\GuiOptions.obj 1


I've gotten unresolved external symbol errors before, but I cannot seem to figure this out.  Any help? 
#14
Help requests / Re: Callbacks with the ComboBox
31 December 2014, 21:12:07
Attempting to bind the callback gives me the following error:

1>e:\gamedev\c++\byte\byte\guioptions.cpp(59): error C3867: 'GuiOptions::resolutionCallback': function call missing argument list; use '&GuiOptions::resolutionCallback' to create a pointer to member

void resolutionCallback(const tgui::Callback& callback);
void GuiOptions::resolutionCallback(const tgui::Callback& callback)
{
selectedResolution = callback.text;
std::cout << selectedResolution << std::endl;
}
#15
Help requests / Callbacks with the ComboBox
29 December 2014, 03:55:19
Hello!  I am attempting to work with callbacks with the ComboBox.  How do I know what is selected in the box?
#16
Thanks, this worked!  xD 

Also, because I couldn't find it anywhere else, how do you skin the buttons?  I haven't really found a tutorial by the developer or any third party that shows how to do this. 
#17
Hello!  I am trying to set up a GUI system.  However, my RenderWindow instance is inside of a different class than what I am trying to access it from, and I can only access it via a RenderWindow*.  Is there a way to set the tgui::Gui to the RenderWindow* that I have, or do I need to do something else?  (Sorry if this is a little noob, I'm not that awesome at C++)
#18
It worked for me as well.  :P  I'm not sure how moving the dlls from dropbox fixed them, but it works now.  Thanks for helping! 
#19
I do have VS2010 SP1 installed.  Here is a link to my project:

https://www.dropbox.com/sh/du3l7ms4bboetf3/QdVpctfjbc
#20
I selected Visual Studio 10.  Is it possibly because of conflicting bits (x32 and x64)?
#21
I downloaded that program, and i get the following output in the bottom window (I selected the .exe file that was compiled with Release):


Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

#22
Setting that in Linker Optimization did not work.  Here is a link to my lib, include and dll files:

https://www.dropbox.com/sh/8amwvbbvb4rsf3b/SPCpvxLiAW
#23
I have built TGUI for VS2010, and my SFML is also for VS2010.  I built TGUI for both Debug and Release dynamically, and have linked the files.  SFML is also linked dynamically.  I still receive the error.
#24
Hello!  I am getting the following error when I attempt to run my program:


The procedure entry point ?begin@String@sf@QAE?AV?$_String_iterator@V?$_String_val@U?$_Simple_types@I@std@@@std@@@std@@XZ could not be located in the dynamic link library sfml-system-2.dll.


This error occurs during runtime before a window appears.  This error only appeared after the installation of TGUI, which leads me to believe that it is the cause.  I have tried both the version of TGUI that the download includes and building it.  I am using VS2010.  Here is the .cpp file and the .hpp relevant line:



#pragma once

#include "ResourceHolder.hpp"
#include "ResourceIdentifiers.hpp"
#include "Player.hpp"
#include "StateStack.hpp"

#include <SFML/System/Time.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Text.hpp>

#include <TGUI\TGUI.hpp>


class Application
{
private:
sf::RenderWindow mWindow;
tgui::Gui mGui;

};


and here is the complete .cpp file:


#include "Application.hpp"
#include "Utility.hpp"
#include "State.hpp"
#include "StateIdentifiers.hpp"
#include "TitleState.hpp"
#include "GameState.hpp"
#include "MenuState.hpp"
#include "PauseState.hpp"

const sf::Time Application::timePerFrame = sf::seconds(1.f/60.f);

Application::Application()
: mWindow(sf::VideoMode(640, 480), "States", sf::Style::Close)
, mGui(mWindow)
, mTextures()
, mFonts()
, mPlayer()
, mStateStack(State::Context(mWindow, mTextures, mFonts, mPlayer))
, mStatisticsText()
, mStatisticsUpdateTime()
, mStatisticsNumFrames(0)
{
mWindow.setKeyRepeatEnabled(false);

mFonts.load(Fonts::Main, "Media/Sansation.ttf");
mTextures.load(Textures::TitleScreen, "Media/Textures/TitleScreen.png");

mStatisticsText.setFont(mFonts.get(Fonts::Main));
mStatisticsText.setPosition(5.f, 5.f);
mStatisticsText.setCharacterSize(10u);

mGui.setGlobalFont(mFonts.get(Fonts::Main));

registerStates();
mStateStack.pushState(States::Menu);
}


void Application::registerStates()
{
mStateStack.registerState<MenuState>(States::Menu);
mStateStack.registerState<GameState>(States::Game);
mStateStack.registerState<PauseState>(States::Pause);
}

void Application::run()
{
sf::Clock clock;
sf::Time timeSinceLastUpdate = sf::Time::Zero;

while (mWindow.isOpen())
{
sf::Time dt = clock.restart();
timeSinceLastUpdate += dt;
while (timeSinceLastUpdate > timePerFrame)
{
timeSinceLastUpdate -= timePerFrame;

processInput();
update(timePerFrame);

// Check inside this loop, because stack might be empty before update() call
if (mStateStack.isEmpty())
mWindow.close();
}

updateStatistics(dt);
render();
}
}

void Application::processInput()
{
sf::Event event;
while (mWindow.pollEvent(event))
{
mStateStack.handleEvent(event);
mGui.handleEvent(event);

if (event.type == sf::Event::Closed)
mWindow.close();
}
}

void Application::update(sf::Time dt)
{
mStateStack.update(dt);
}

void Application::render()
{
mWindow.clear();

mStateStack.draw();

mWindow.setView(mWindow.getDefaultView());
mWindow.draw(mStatisticsText);

mGui.draw();

mWindow.display();
}

void Application::updateStatistics(sf::Time dt)
{
mStatisticsUpdateTime += dt;
mStatisticsNumFrames += 1;
if (mStatisticsUpdateTime >= sf::seconds(1.0f))
{
mStatisticsText.setString("FPS: " + toString(mStatisticsNumFrames));

mStatisticsUpdateTime -= sf::seconds(1.0f);
mStatisticsNumFrames = 0;
}
}



Any ideas?