From 58a14d0b9fae397cbe874d4baac90d15d92065a1 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 29 Jan 2011 20:18:30 +0100 Subject: Allow setting window title. --- application.cpp | 12 +++++++----- application.h | 8 ++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/application.cpp b/application.cpp index b92b9a3..8cd9e9d 100644 --- a/application.cpp +++ b/application.cpp @@ -15,17 +15,19 @@ Application::~Application() { } -void Application::create_window(unsigned int w, unsigned int h, bool fs) { - window->Create(sf::VideoMode(w, h, 32), "Foo", sf::Style::Resize | sf::Style::Close | (fs ? sf::Style::Fullscreen : 0)); +void Application::create_window(unsigned int w, unsigned int h, bool fs, const std::string& title) { + window->Create(sf::VideoMode(w, h, 32), title, sf::Style::Resize | sf::Style::Close | (fs ? sf::Style::Fullscreen : 0)); window->UseVerticalSync(true); } -void Application::init_window(unsigned int w, unsigned int h, bool fs) { +void Application::init_window(unsigned int w, unsigned int h, bool fs, const std::string& title) { renderwindow = new sf::RenderWindow(); window = renderwindow; - create_window(w, h, fs); + create_window(w, h, fs, title); input_backend = &window->GetInput(); + + window_title = title; } void Application::run() { @@ -76,7 +78,7 @@ void Application::event_keypress(sf::Key::Code key) { break; case sf::Key::F: fullscreen = !fullscreen; - create_window(1024, 768, fullscreen); + create_window(1024, 768, fullscreen, window_title); event_reshape(window->GetWidth(), window->GetHeight()); init(); break; diff --git a/application.h b/application.h index f7ea563..8f1bb35 100644 --- a/application.h +++ b/application.h @@ -1,6 +1,8 @@ #ifndef APPLICATION_H #define APPLICATION_H +#include + #include #include "input.h" @@ -10,9 +12,11 @@ class Application { bool please_quit; bool fullscreen; + std::string window_title; + protected: - void create_window(unsigned int w, unsigned int h, bool fs = false); - void init_window(unsigned int w, unsigned int h, bool fs = false); + void create_window(unsigned int w, unsigned int h, bool fs, const std::string& title); + void init_window(unsigned int w, unsigned int h, bool fs, const std::string& title); virtual void event(const sf::Event& e); virtual void event_keypress(Key::Code key); -- cgit v1.2.3