Welcome, Guest. Please login or register. Did you miss your activation email?

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 - Parsley

Pages: [1]
1
SFML projects / Re: This Grand Life
« on: October 24, 2017, 04:03:04 am »
Thanks binary1248, I'll have a look into disabling the refresh!

2
SFML projects / Re: This Grand Life
« on: October 23, 2017, 10:52:26 pm »
Hi Tank, thanks for making SFGUI, it's really great and made the UI aspects so much easier to handle!

I have attached the theme.txt, where each of the theme IDs are grouped together. I'm loading it using:

desktop.LoadThemeFromFile("theme.txt");

The above part takes maybe 50% of the time (very roughly). Then for each theme ID in that file I call the below SetGenericDesktopSettings for the font size, which takes maybe 25% of the time. I set the font size in the app rather than the .txt file because it can change depending on the player's settings.

SetGenericDesktopSettings(sfg::Desktop& desktop, std::string id)
{
    //Widget types
    std::vector<std::string> widgets;
    widgets.push_back("Button");
    widgets.push_back("Label");
    widgets.push_back("Frame");
    widgets.push_back("Entry");

    std::vector<std::string>::iterator itW = widgets.begin();
    while(itW != widgets.end())
    {
        //Set font sizes
        std::string fontStr = *itW + "#" + id + *itW;
        std::string largeFontStr = *itW + "#" + id + "Large" + *itW;
        desktop.SetProperty(fontStr, "FontSize", m_imageM->GetDefaultCharSize());
        desktop.SetProperty(largeFontStr, "FontSize", m_imageM->GetDefaultLargeCharSize());

        ++itW;
    }
}

Sorry I can't provide a complete example, the way I load the theme ID strings is a bit more complicated and too large to paste here.

3
SFML projects / Re: This Grand Life
« on: October 21, 2017, 09:47:39 pm »
I hadn't thought about using the enter key to close the popup windows, I'll look into that  :)

4
SFML projects / Re: It Usually Ends In Nuclear War
« on: October 20, 2017, 07:45:38 am »
This looks cool! Did you end up multithreading it since the last update? I multithreaded my game but then people started reporting random crashes every few hours and I got paranoid and single threaded it. It's really hard to do and increases the code complexity by so much.

5
SFML projects / Re: This Grand Life
« on: October 20, 2017, 01:56:13 am »
Thanks for the kind words. I've never used Linux before or ported to it so have no idea how hard it would be. I know SFML is compatible so at least that angle's covered. If the game gets popular enough I might look into it, but at the moment there's no plans for anything other than Windows PC.

6
SFML projects / Re: SFGUI (0.3.2 released)
« on: October 19, 2017, 12:33:12 pm »
There used to be a reference page for widget properties but it's disappeared since they took the old website down. For the window titlebar the property is called 'TitleBackgroundColor'. Label text color I *think* the property is just called 'Color'.

7
SFML projects / Re: This Grand Life
« on: October 19, 2017, 12:02:42 am »
@FRex I've actually got about 20 different skins/themes which I've defined in a .txt file, and each location has a unique skin. It takes a long time to load them all (about 75% of startup time) but is worth it in the end! I did try using the built-in close button initially but from memory I ran into trouble with it. I think it was 'sticky' or maybe didn't feel like I was clicking it when I thought I did or something? I ended up rolling my own close that I can just Pack() in anywhere.

@Mario I'm not sure there's rounded edge functionality in SFGUI, at least I haven't encountered it.

@eXpl0it3r Yes Tribe Of Pok also used SFML, I totally forgot. I didn't use SFGUI though, I rolled my own UI and it was a nightmare!

8
SFML projects / Re: This Grand Life
« on: October 18, 2017, 03:30:20 pm »
Thanks, I'll get in contact with that SFML Projects as well!

9
SFML projects / This Grand Life
« on: October 18, 2017, 02:05:32 pm »
Hey everyone,

I've been working on a project using SFML for a while now, and didn't realize this subforum for our projects existed here! It's written in C++, I use all the SFML modules except networking and also use SFGUI for the user interface.

My project is This Grand Life, a personal finance simulator where you create a character, manage their money and help them achieve their life goals.

You can download a demo from Itch.io or IndieDB.

It's also going to be coming to Steam on 23rd October, 2017.


Here's a list of features and screenshots:


  • Balancing Needs - Core game loop of balancing short-term needs such as hunger, fun, hygiene and health with long-term goals like happiness, wealth and education.


  • Stylised City Maps - The game map is based on a real major city, thanks to satellite imagery from the European Space Agency!


  • Education System - Study courses and graduate with qualifications, required for some higher level occupations.


  • Careers and Employment - Prestigious career paths like Banking and Chef, plus lower level occupations like Janitor and Salesperson.


  • Progressive Taxation System - The more you earn, the higher your tax bracket.


  • Possessions - Fridges, TVs and Computers which help with your short-term needs.


  • Collectibles - Collect stamps, coins and other rare items to achieve your long-term goals.


  • Subscription Services - Sign up for services that make life easier, like grocery delivery or cable TV.


  • Special Events - Home Robbery, Hotdog Eating Competition, Steam Sales and more.
  • Investment and Debt - Borrow money to achieve your goals or invest for a future where you won't have to work. Minimum repayments and interest rates calculated realistically.


  • Real Estate - Buy properties through an auction system. Live in it yourself or rent out your properties to tenants.


  • Life Expenses - Electricity bills, rent, loan repayments and consequences for not paying them on time.


  • Traits/Privilege System - Begin life with advantages like rich parents, or disadvantages like alcoholism.


  • Tutorial - An interactive tutorial where your mother tells you to get a job.


If any of you have played Jones In The Fast Lane, it is my inspiration for creating This Grand Life!


10
SFML projects / Re: SFGUI (0.3.2 released)
« on: July 29, 2017, 02:08:31 pm »
Ok I found another way of doing what I wanted. I keep a vector of all the windows I've created in the main desktop, and when I go to look at the second desktop I hide all the visible windows and store the ones I've hidden in a separate list. Then when it's time to unhide them, I go through that list and call Show(true):

Quote
        std::vector<sfg::Window::Ptr> m_allWindows;
        std::vector<sfg::Window::Ptr> m_hiddenWindows; //For storing which ones were visible

void HideAllVisibleWindows()
{
    std::vector<sfg::Window::Ptr>::iterator itW = m_allWindows.begin();
    while(itW != m_allWindows.end())
    {
        if((*itW)->IsGloballyVisible())
        {
            (*itW)->Show(false);
            m_hiddenWindows.push_back(*itW);
        }

        ++itW;
    }
}

void ShowAllVisibleWindows()
{
    std::vector<sfg::Window::Ptr>::iterator itW = m_hiddenWindows.begin();
    while(itW != m_hiddenWindows.end())
    {
        (*itW)->Show(true);

        ++itW;
    }
    m_hiddenWindows.clear();
}


11
SFML projects / Re: SFGUI (0.3.2 released)
« on: July 27, 2017, 04:28:05 pm »
Hi Theo,

Thanks for your suggestions. My problem is that in my app I'm trying to keep the first desktop in its current state (of which windows are showing and which are hidden) while the user is interacting with the second desktop. Then when the user is done with the second desktop, they can go back to the first desktop with only the windows they already had open showing (I have about 30-40 windows in the first desktop - it's a big program).

I'm experimenting with adding something like below to desktop.hpp, but it's not quite working yet:

Quote
      WidgetsList m_hidden;

      void HideDesktop(){
            WidgetsList::iterator itD = m_children.begin();
            while(itD != m_children.end()){
                if((*itD)->IsGloballyVisible()){ //if currently visible, hide it
                    m_hidden.push_back(*itD);
                    (*itD)->Show(false);
                }

                ++itD;
            }
      }

      void ShowDesktop(){
            WidgetsList::iterator itD = m_children.begin();
            while(itD != m_children.end()){
                WidgetsList::iterator itW = m_hidden.begin();
                while(itW != m_hidden.end()){
                    if(*itD == *itW){ //If found in hidden list
                        (*itD)->Show(true);
                    }
                }

                ++itD;
            }
            m_hidden.clear(); //All showing so none should be hidden
      }


12
SFML projects / Re: SFGUI (0.3.2 released)
« on: July 25, 2017, 09:08:26 am »
Hi,

I'm having trouble figuring out how to show/hide multiple sfg::Desktop in the same sf::RenderWindow. Is it possible in the current version of SFGUI? Here is a modified version of the sfgui desktop example, where I have put the second sfg::Window in a separate desktop:

Quote
#include <SFGUI/SFGUI.hpp>
#include <SFGUI/Widgets.hpp>

#include <SFML/Graphics.hpp>
#include <sstream>

class DesktopExample {
   public:
      DesktopExample();

      void Run();

   private:
      static const unsigned int SCREEN_WIDTH;
      static const unsigned int SCREEN_HEIGHT;

      void OnCreateWindowClick();
      void OnDestroyWindowClick();
      void OnFrontClick();

      // Create an SFGUI. This is required before doing anything with SFGUI.
      sfg::SFGUI m_sfgui;

      sfg::Desktop m_desktop;
      sfg::Desktop m_desktop2;
      sfg::Window::Ptr m_window;
      unsigned int m_count;

      bool m_is_second;
};

const unsigned int DesktopExample::SCREEN_WIDTH = 800;
const unsigned int DesktopExample::SCREEN_HEIGHT = 600;

int main() {
   DesktopExample app;
   app.Run();

   return 0;
}

DesktopExample::DesktopExample() :
   m_desktop(),
   m_desktop2(),
   m_window( sfg::Window::Create() ),
   m_count( 0 ),
   m_is_second(false)
{
}

void DesktopExample::Run() {
   sf::RenderWindow render_window( sf::VideoMode( SCREEN_WIDTH, SCREEN_HEIGHT ), "SFGUI Desktop Example" );
   sf::Event event;

   // We have to do this because we don't use SFML to draw.
   render_window.resetGLStates();

   // Init.
   m_desktop.SetProperty( "Button#create_window", "FontSize", 18.f );

   //// Main window ////
   // Widgets.
   m_window->SetTitle( "SFGUI Desktop Example" );

   auto intro_label = sfg::Label::Create( "Click on \"Create window\" to create any number of new windows." );
   auto create_window_button = sfg::Button::Create( "Create window" );
   create_window_button->SetId( "create_window" );

   // Layout.
   auto main_box = sfg::Box::Create( sfg::Box::Orientation::VERTICAL, 5.f );
   main_box->Pack( intro_label, false );
   main_box->Pack( create_window_button, false );

   m_window->Add( main_box );
   m_desktop.Add( m_window );

   // Signals.
   create_window_button->GetSignal( sfg::Widget::OnLeftClick ).Connect( std::bind( &DesktopExample::OnCreateWindowClick, this ) );

   while( render_window.isOpen() ) {
      while( render_window.pollEvent( event ) ) {
         if(
            (event.type == sf::Event::Closed) ||
            (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape)
         ) {
            render_window.close();
         }
         else {
                if(m_is_second){
                    m_desktop2.HandleEvent( event );
                }
                else
                {
                    m_desktop.HandleEvent( event );
                }

         }
      }

      m_desktop2.Update( 0.f );
      m_desktop.Update( 0.f );

      render_window.clear();
      m_sfgui.Display( render_window );
      render_window.display();
   }
}

void DesktopExample::OnCreateWindowClick() {
   ++m_count;

   m_is_second = true;

   // Create a new window.
   auto window = sfg::Window::Create();

   std::stringstream sstr;
   sstr << "A new window (" << m_count << ")";
   window->SetTitle( sstr.str() );

   // Widgets.
   auto destroy_button = sfg::Button::Create( "Destroy" );
   auto front_button = sfg::Button::Create( "Main window to front" );

   // Layout.
   auto box = sfg::Box::Create( sfg::Box::Orientation::VERTICAL, 5.f );
   box->Pack( sfg::Label::Create( "This is a newly created window, from runtime, interactively." ), false );
   box->Pack( sfg::Label::Create( "You can move me around, try it!" ), false );
   box->Pack( sfg::Label::Create( "Or click the button below to destroy me. :-(" ), false );
   box->Pack( destroy_button, false );
   box->Pack( front_button, false );

   window->Add( box );
   m_desktop2.Add( window );

   // Signals.
   destroy_button->GetSignal( sfg::Widget::OnLeftClick ).Connect( std::bind( &DesktopExample::OnDestroyWindowClick, this ) );
   front_button->GetSignal( sfg::Widget::OnLeftClick ).Connect( std::bind( &DesktopExample::OnFrontClick, this ) );
}

void DesktopExample::OnDestroyWindowClick() {
    m_is_second = false;
   // Obtain parent window.
   auto widget = sfg::Context::Get().GetActiveWidget();

   while( widget->GetName() != "Window" ) {
      widget = widget->GetParent();
   }

   // Remove window from desktop.
   m_desktop2.Remove( widget );
}

void DesktopExample::OnFrontClick() {
   m_desktop.BringToFront( m_window );
}

As you can see, I can make it so the first desktop is not interact-able when the second window is created in the second desktop by using:

Quote
                if(m_is_second){
                    m_desktop2.HandleEvent( event );
                }
                else
                {
                    m_desktop.HandleEvent( event );
                }

But the "SFGUI Desktop Example" window (contained in the first desktop) is still visible. Is there a way to hide the first desktop?

I know I can use hide/show on the sfg::Window, but is there a way to hide/show the desktop itself? I don't want to RemoveAll() the widgets from the first desktop either, as in my app the second desktop is an in-game menu. So the player would briefly visit this second desktop and then quickly return to the first desktop in its current state.

13
Graphics / Texture Splatting with VertexArrays
« on: March 23, 2016, 12:55:42 pm »
I'm trying to implement texture splatting but having trouble figuring out how to do it with SFML/OpenGL. I have an sf::VertexArray where I store my tile map, like so:



Each tile is drawn with its own Quad in the VertexArray. According to Texture Splatting I am supposed to pass two textures to the shader and alpha blend them in there. Is it possible to blend the Quad that is underneath with the Quad that is on top (e.g make it so some of the sand and dirt shows through on the grass Quad), and if so how would I do it? Or is the information underneath the grass Quad "lost" by the time it gets to the shader, and so the shader would not be able to manipulate it?

I hope my question makes sense

Pages: [1]
anything