[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src display.cpp display.hpp preferences...
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src display.cpp display.hpp preferences... |
Date: |
Wed, 26 Jan 2005 22:45:01 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 05/01/27 03:45:01
Modified files:
src : display.cpp display.hpp preferences.cpp
preferences.hpp game.cpp
Log message:
added the --fps option to display the number of fps the game is running
at in-game
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.284&tr2=1.285&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.hpp.diff?tr1=1.90&tr2=1.91&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/preferences.cpp.diff?tr1=1.129&tr2=1.130&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/preferences.hpp.diff?tr1=1.45&tr2=1.46&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.182&tr2=1.183&r1=text&r2=text
Patches:
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.284 wesnoth/src/display.cpp:1.285
--- wesnoth/src/display.cpp:1.284 Fri Dec 31 21:01:37 2004
+++ wesnoth/src/display.cpp Thu Jan 27 03:45:00 2005
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.284 2004/12/31 21:01:37 isaaccp Exp $ */
+/* $Id: display.cpp,v 1.285 2005/01/27 03:45:00 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -78,7 +78,7 @@
theme_(theme_cfg,screen_area()), builder_(cfg, level, map),
first_turn_(true), in_game_(false), map_labels_(*this,map),
tod_hex_mask1(NULL), tod_hex_mask2(NULL), diagnostic_label_(0),
- help_string_(0)
+ help_string_(0), fps_handle_(0)
{
if(non_interactive())
updatesLocked_++;
@@ -670,12 +670,15 @@
//TODO: review whether this is the correct thing to do
SDL_Delay(maximum<int>(10,wait_time));
- if(update) {
- lastDraw_ = SDL_GetTicks();
+ if(update) {
+ const int thisDraw = SDL_GetTicks();
+ const int latency = thisDraw - lastDraw_;
+ lastDraw_ = thisDraw;
if(wait_time >= 0 || drawSkips_ >= max_skips || force) {
- if(changed)
- update_display();
+ if(changed) {
+ update_display();
+ }
} else {
drawSkips_++;
}
@@ -686,6 +689,31 @@
{
if(updatesLocked_ > 0)
return;
+
+ if(preferences::show_fps()) {
+ static int last_sample = SDL_GetTicks();
+ static int frames = 0;
+ ++frames;
+
+ if(frames == 10) {
+ const int this_sample = SDL_GetTicks();
+
+ const int fps = (frames*1000)/(this_sample -
last_sample);
+ last_sample = this_sample;
+ frames = 0;
+
+ if(fps_handle_ != 0) {
+ font::remove_floating_label(fps_handle_);
+ fps_handle_ = 0;
+ }
+ std::ostringstream stream;
+ stream << fps << "fps";
+ fps_handle_ =
font::add_floating_label(stream.str(),12,font::NORMAL_COLOUR,10,100,0,0,-1,screen_area(),font::LEFT_ALIGN);
+ }
+ } else if(fps_handle_ != 0) {
+ font::remove_floating_label(fps_handle_);
+ fps_handle_ = 0;
+ }
screen_.flip();
}
Index: wesnoth/src/display.hpp
diff -u wesnoth/src/display.hpp:1.90 wesnoth/src/display.hpp:1.91
--- wesnoth/src/display.hpp:1.90 Fri Dec 31 00:46:41 2004
+++ wesnoth/src/display.hpp Thu Jan 27 03:45:00 2005
@@ -1,4 +1,4 @@
-/* $Id: display.hpp,v 1.90 2004/12/31 00:46:41 Sirp Exp $ */
+/* $Id: display.hpp,v 1.91 2005/01/27 03:45:00 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -507,7 +507,10 @@
int help_string_;
//animated flags for each team
- std::vector<animated<image::locator> > flags_;
+ std::vector<animated<image::locator> > flags_;
+
+ //the handle for the label which displays fps
+ int fps_handle_;
};
//an object which will lock the display for the duration of its lifetime.
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.182 wesnoth/src/game.cpp:1.183
--- wesnoth/src/game.cpp:1.182 Tue Jan 25 23:18:54 2005
+++ wesnoth/src/game.cpp Thu Jan 27 03:45:00 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.182 2005/01/25 23:18:54 ydirson Exp $ */
+/* $Id: game.cpp,v 1.183 2005/01/27 03:45:00 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -383,8 +383,10 @@
if(val.empty()) {
continue;
}
-
- if(val == "--nocache") {
+
+ if(val == "--fps") {
+ preferences::set_show_fps(true);
+ } else if(val == "--nocache") {
use_caching_ = false;
} else if(val == "--resolution" || val == "-r") {
if(arg_+1 != argc_) {
Index: wesnoth/src/preferences.cpp
diff -u wesnoth/src/preferences.cpp:1.129 wesnoth/src/preferences.cpp:1.130
--- wesnoth/src/preferences.cpp:1.129 Fri Jan 21 23:34:48 2005
+++ wesnoth/src/preferences.cpp Thu Jan 27 03:45:00 2005
@@ -1,4 +1,4 @@
-/* $Id: preferences.cpp,v 1.129 2005/01/21 23:34:48 Sirp Exp $ */
+/* $Id: preferences.cpp,v 1.130 2005/01/27 03:45:00 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -50,7 +50,9 @@
bool haloes = true;
-bool unit_genders = true;
+bool unit_genders = true;
+
+bool fps = false;
std::set<std::string> encountered_units_set;
std::set<std::string> encountered_terrains_set;
@@ -702,6 +704,16 @@
{
haloes = value;
prefs["show_haloes"] = value ? "yes" : "no";
+}
+
+bool show_fps()
+{
+ return fps;
+}
+
+void set_show_fps(bool value)
+{
+ fps = value;
}
std::set<std::string> &encountered_units() {
Index: wesnoth/src/preferences.hpp
diff -u wesnoth/src/preferences.hpp:1.45 wesnoth/src/preferences.hpp:1.46
--- wesnoth/src/preferences.hpp:1.45 Fri Jan 21 23:34:48 2005
+++ wesnoth/src/preferences.hpp Thu Jan 27 03:45:00 2005
@@ -1,4 +1,4 @@
-/* $Id: preferences.hpp,v 1.45 2005/01/21 23:34:48 Sirp Exp $ */
+/* $Id: preferences.hpp,v 1.46 2005/01/27 03:45:00 Sirp Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -144,7 +144,10 @@
void set_show_tip_of_day(bool value);
bool show_haloes();
- void set_show_haloes(bool value);
+ void set_show_haloes(bool value);
+
+ bool show_fps();
+ void set_show_fps(bool value);
std::set<std::string> &encountered_units();
std::set<std::string> &encountered_terrains();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src display.cpp display.hpp preferences...,
David White <=