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 (https://pokingwatergames.itch.io/this-grand-life) or IndieDB (http://www.indiedb.com/games/this-grand-life/downloads).
It's also going to be coming to Steam (http://store.steampowered.com/app/695600/This_Grand_Life/) on 23rd October, 2017.
This Grand Life (https://www.youtube.com/watch?v=3lfXpxK-j2s)
Here's a list of features and screenshots:
(http://pokingwatergames.com/wp-content/uploads/2017/10/20170910-PaintHome2c-1024x576.png)
- 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.
(http://pokingwatergames.com/wp-content/uploads/2017/03/20170329-Home.gif)
- Stylised City Maps - The game map is based on a real major city, thanks to satellite imagery from the European Space Agency!
(http://pokingwatergames.com/wp-content/uploads/2017/03/20170311-SydneyBeforeAfter.gif)
- Education System - Study courses and graduate with qualifications, required for some higher level occupations.
(http://pokingwatergames.com/wp-content/uploads/2017/06/20170701-UniScreen-1024x576.png)
- Careers and Employment - Prestigious career paths like Banking and Chef, plus lower level occupations like Janitor and Salesperson.
(http://pokingwatergames.com/wp-content/uploads/2017/03/20170329-Work.gif)
- Progressive Taxation System - The more you earn, the higher your tax bracket.
(http://pokingwatergames.com/wp-content/uploads/2017/05/201705014-NapoleonCatTax.png)
- Possessions - Fridges, TVs and Computers which help with your short-term needs.
(http://pokingwatergames.com/wp-content/uploads/2017/05/201705021-Possessions.png)
- Collectibles - Collect stamps, coins and other rare items to achieve your long-term goals.
(http://pokingwatergames.com/wp-content/uploads/2017/05/201705026-Jewellery-Collection-1-1024x576.png)
- Subscription Services - Sign up for services that make life easier, like grocery delivery or cable TV.
(http://pokingwatergames.com/wp-content/uploads/2017/05/20170604-Subscriptions.png)
- 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.
(http://pokingwatergames.com/wp-content/uploads/2017/05/201705021-Mortgage.png)
- Real Estate - Buy properties through an auction system. Live in it yourself or rent out your properties to tenants.
(http://pokingwatergames.com/wp-content/uploads/2017/05/201705021-RentOut.png)
- Life Expenses - Electricity bills, rent, loan repayments and consequences for not paying them on time.
(http://pokingwatergames.com/wp-content/uploads/2017/05/201705014-NapoleonIncStatement.png)
- Traits/Privilege System - Begin life with advantages like rich parents, or disadvantages like alcoholism.
(http://pokingwatergames.com/wp-content/uploads/2017/03/20170320-ChooseProfile.png)
- Tutorial - An interactive tutorial where your mother tells you to get a job.
(http://pokingwatergames.com/wp-content/uploads/2017/03/20170322-TutorialSmall.png)
If any of you have played Jones In The Fast Lane, it is my inspiration for creating This Grand Life!
Steam (http://store.steampowered.com/app/695600) | Itch.io (https://pokingwatergames.itch.io/this-grand-life) | Twitter (https://twitter.com/ParsleyPWG) | Website (http://pokingwatergames.com/)
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.
SFGUI theme loading is a bit "suboptimal". It causes a widget hierarchy refresh for every statement read from the file, which given a big enough file and enough widgets can lead to a lot of waiting.
Either load the theme file and set the font sizes before creating all your widgets or manually take care of refreshing once you know you are done. Something like this:
#include <SFGUI/Engines/BREW.hpp>
...
class MyOptimizedBREW : public sfg::eng::BREW
{
public:
void SetAutoRefresh( bool enable ) { sfg::eng::BREW::SetAutoRefresh( enable ); }
};
...
desktop.UseEngine<MyOptimizedBREW>();
...
MyOptimizedBREW& engine = static_cast<MyBREW&>(desktop.GetEngine());
engine.SetAutoRefresh(false);
desktop.LoadThemeFromFile("theme.txt");
SetGenericDesktopSettings(desktop, ...);
engine.SetAutoRefresh(true);
sfg::Widget::RefreshAll();