Implemented adjustable framerate control
Simplified calls to Message() SPStrN() and adding empty lines to CSPList git-svn-id: https://svn.code.sf.net/p/extremetuxracer/code/trunk@447 0420edf4-82e4-42fc-9478-35b55e6d67a3master
parent
2745a24f10
commit
1ec2d11761
|
@ -93,8 +93,8 @@ void CSound::LoadSoundList () {
|
|||
if (list.Load (param.sounds_dir, "sounds.lst")) {
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
string name = SPStrN (line, "name", "");
|
||||
string soundfile = SPStrN (line, "file", "");
|
||||
string name = SPStrN (line, "name");
|
||||
string soundfile = SPStrN (line, "file");
|
||||
string path = MakePathStr (param.sounds_dir, soundfile);
|
||||
LoadChunk (name, path.c_str());
|
||||
}
|
||||
|
@ -233,8 +233,8 @@ void CMusic::LoadMusicList () {
|
|||
if (list.Load (param.music_dir, "music.lst")) {
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
string name = SPStrN (line, "name", "");
|
||||
string musicfile = SPStrN (line, "file", "");
|
||||
string name = SPStrN (line, "name");
|
||||
string musicfile = SPStrN (line, "file");
|
||||
string path = MakePathStr (param.music_dir, musicfile);
|
||||
LoadPiece (name, path.c_str());
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ void CMusic::LoadMusicList () {
|
|||
themes.resize(list.Count());
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
string name = SPStrN (line, "name", "");
|
||||
string name = SPStrN (line, "name");
|
||||
ThemesIndex[name] = i;
|
||||
string item = SPStrN (line, "race", "race_1");
|
||||
themes[i].situation[0] = musics[MusicIndex[item]];
|
||||
|
@ -310,7 +310,7 @@ void CMusic::Update () {
|
|||
}
|
||||
|
||||
bool CMusic::Play (Mix_Music* music, int loop, int volume) {
|
||||
if(!music)
|
||||
if (!music)
|
||||
return false;
|
||||
|
||||
int vol = clamp(0, volume, MIX_MAX_VOLUME);
|
||||
|
|
|
@ -158,6 +158,11 @@ void Message (const string& a, const string& b) {
|
|||
msg_list.Add (a + b);
|
||||
}
|
||||
|
||||
void Message (const string& msg) {
|
||||
cout << msg << endl;
|
||||
msg_list.Add (msg);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// file utils
|
||||
// --------------------------------------------------------------------
|
||||
|
|
|
@ -98,6 +98,7 @@ bool DirExists (const char *dirname);
|
|||
void Message (const char *msg, const char *desc);
|
||||
void Message (const char *msg);
|
||||
void Message (const string& a, const string& b);
|
||||
void Message (const string& a);
|
||||
void SaveMessages ();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
|
@ -222,7 +222,7 @@ void CCourse::MakeCourseNormals () {
|
|||
nmls = new TVector3[nx * ny];
|
||||
} catch (...) {
|
||||
nmls = NULL;
|
||||
Message ("Allocation failed in MakeCourseNormals" , "");
|
||||
Message ("Allocation failed in MakeCourseNormals");
|
||||
}
|
||||
CalcNormals ();
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ void CCourse::LoadItemList () {
|
|||
double xx = (nx - x) / (double)(nx - 1.0) * curr_course->size.x;
|
||||
double zz = -(ny - z) / (double)(ny - 1.0) * curr_course->size.y;
|
||||
|
||||
string name = SPStrN (line, "name", "");
|
||||
string name = SPStrN (line, "name");
|
||||
size_t type = ObjectIndex[name];
|
||||
if (ObjTypes[type].texture == NULL && ObjTypes[type].drawable) {
|
||||
string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile;
|
||||
|
@ -584,13 +584,13 @@ bool CCourse::LoadObjectTypes () {
|
|||
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
ObjTypes[i].name = SPStrN (line, "name", "");
|
||||
ObjTypes[i].name = SPStrN (line, "name");
|
||||
ObjTypes[i].textureFile = ObjTypes[i].name;
|
||||
ObjTypes[i].texture = NULL;
|
||||
|
||||
ObjTypes[i].drawable = SPBoolN (line, "draw", true);
|
||||
if (ObjTypes[i].drawable) {
|
||||
ObjTypes[i].textureFile = SPStrN (line, "texture", "");
|
||||
ObjTypes[i].textureFile = SPStrN (line, "texture");
|
||||
}
|
||||
ObjTypes[i].collectable = SPBoolN (line, "snap", -1) != 0;
|
||||
if (ObjTypes[i].collectable == 0) {
|
||||
|
@ -641,8 +641,8 @@ bool CCourse::LoadTerrainTypes () {
|
|||
TerrList.resize(list.Count());
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
TerrList[i].textureFile = SPStrN (line, "texture", "");
|
||||
TerrList[i].sound = SPStrN (line, "sound", "");
|
||||
TerrList[i].textureFile = SPStrN (line, "texture");
|
||||
TerrList[i].sound = SPStrN (line, "sound");
|
||||
TerrList[i].starttex = SPIntN (line, "starttex", -1);
|
||||
TerrList[i].tracktex = SPIntN (line, "tracktex", -1);
|
||||
TerrList[i].stoptex = SPIntN (line, "stoptex", -1);
|
||||
|
@ -670,13 +670,13 @@ bool CCourse::LoadTerrainMap () {
|
|||
return false;
|
||||
}
|
||||
if (nx != terrImage.nx || ny != terrImage.ny) {
|
||||
Message ("wrong terrain size", "");
|
||||
Message ("wrong terrain size");
|
||||
}
|
||||
|
||||
try {
|
||||
terrain = new char[nx * ny];
|
||||
} catch (...) {
|
||||
Message ("Allocation failed in LoadTerrainMap", "");
|
||||
Message ("Allocation failed in LoadTerrainMap");
|
||||
}
|
||||
int pad = 0;
|
||||
for (int y=0; y<ny; y++) {
|
||||
|
@ -715,7 +715,7 @@ bool CCourse::LoadCourseList () {
|
|||
CourseList[i].name = SPStrN (line1, "name", "noname");
|
||||
CourseList[i].dir = SPStrN (line1, "dir", "nodir");
|
||||
|
||||
string desc = SPStrN (line1, "desc", "");
|
||||
string desc = SPStrN (line1, "desc");
|
||||
FT.AutoSizeN (2);
|
||||
vector<string> desclist = FT.MakeLineList (desc.c_str(), 335 * Winsys.scale - 16.0);
|
||||
size_t cnt = min(desclist.size(), MAX_DESCRIPTION_LINES);
|
||||
|
|
|
@ -50,7 +50,7 @@ void CCredits::LoadCreditList () {
|
|||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
TCredits credit;
|
||||
credit.text = SPStrN (line, "text", "");
|
||||
credit.text = SPStrN (line, "text");
|
||||
|
||||
double offset = SPFloatN (line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
|
||||
if (i>0) credit.offs = CreditList.back().offs + (int)offset;
|
||||
|
|
|
@ -135,7 +135,7 @@ bool CEnvironment::LoadEnvironmentList () {
|
|||
locs.resize(list.Count());
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
locs[i] = SPStrN (line, "location", "");
|
||||
locs[i] = SPStrN (line, "location");
|
||||
}
|
||||
list.MakeIndex (EnvIndex, "location");
|
||||
return true;
|
||||
|
@ -167,7 +167,7 @@ void CEnvironment::LoadLight (const string& EnvDir) {
|
|||
|
||||
CSPList list(24);
|
||||
if (!list.Load (EnvDir, "light.lst")) {
|
||||
Message ("could not load light file", "");
|
||||
Message ("could not load light file");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,6 @@ void CEventSelect::Enter () {
|
|||
|
||||
Events.MakeUnlockList (Players.GetCurrUnlocked());
|
||||
Music.Play (param.menu_music, -1);
|
||||
g_game.loopdelay = 20;
|
||||
}
|
||||
|
||||
void CEventSelect::Loop (double timestep) {
|
||||
|
|
|
@ -163,8 +163,8 @@ bool CFont::LoadFontlist () {
|
|||
if (!list.Load ( param.font_dir, "fonts.lst")) return false;
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
string fontfile = SPStrN (line, "file", "");
|
||||
string name = SPStrN (line, "name", "");
|
||||
string fontfile = SPStrN (line, "file");
|
||||
string name = SPStrN (line, "name");
|
||||
|
||||
int ftidx = LoadFont (name, param.font_dir.c_str(), fontfile.c_str());
|
||||
if (ftidx < 0) {
|
||||
|
|
|
@ -58,6 +58,7 @@ void LoadConfigFile () {
|
|||
|
||||
param.fullscreen = SPBoolN (line, "fullscreen", false);
|
||||
param.res_type = SPIntN (line, "res_type", 0);
|
||||
param.framerate = SPIntN (line, "framerate", 60);
|
||||
param.perf_level = SPIntN (line, "detail_level", 0);
|
||||
param.language = SPIntN (line, "language", 0);
|
||||
param.sound_volume = SPIntN (line, "sound_volume", 100);
|
||||
|
@ -88,6 +89,7 @@ void LoadConfigFile () {
|
|||
void SetConfigDefaults () {
|
||||
param.fullscreen = true;
|
||||
param.res_type = 0; // 0=auto / 1=800x600 / 2=1024x768 ...
|
||||
param.framerate = 60;
|
||||
param.perf_level = 3; // detail level
|
||||
param.language = string::npos; // If language is set to npos, ETR will try to load default system language
|
||||
param.sound_volume = 100;
|
||||
|
@ -139,42 +141,47 @@ void SaveConfigFile () {
|
|||
liste.Add ("# The first group of params can be adjusted ");
|
||||
liste.Add ("# on the configuration screen, too");
|
||||
liste.Add ("# ------------------------------------------------------------------");
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Full-screen mode [0...1]");
|
||||
AddIntItem (liste, "fullscreen", param.fullscreen);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Screen resolution [0...9]");
|
||||
AddComment (liste, "0 = auto, 1 = 800x600, 2 = 1024x768");
|
||||
AddComment (liste, "3 = 1152x864, 4 = 1280x960, 5 = 1280x1024");
|
||||
AddComment (liste, "6 = 1360x768, 7 = 1400x1050, 8 = 1440x900, 9=1680x1050");
|
||||
AddIntItem (liste, "res_type", (int)param.res_type);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Framerate limit");
|
||||
AddComment (liste, "0 = unlimited, default: 60");
|
||||
AddIntItem (liste, "framerate", (int)param.framerate);
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Level of details [1...3]");
|
||||
AddComment (liste, "1 = best performance, 3 = best appearance");
|
||||
AddIntItem (liste, "detail_level", param.perf_level);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Language code [0...]");
|
||||
AddComment (liste, "0 = English etc.");
|
||||
AddIntItem (liste, "language", (int)param.language);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Sound volume [0...120]");
|
||||
AddComment (liste, "Sounds are the terrain effects or the pickup noise.");
|
||||
AddIntItem (liste, "sound_volume", param.sound_volume);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Volume of the background music [0...120]");
|
||||
AddIntItem (liste, "music_volume", param.music_volume);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
liste.Add ("# ------------------------------------------------------------------");
|
||||
liste.Add ("# The second group of params must be adjusted in this file.");
|
||||
liste.Add ("# ------------------------------------------------------------------");
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Forward clipping distance");
|
||||
AddComment (liste, "Controls how far ahead of the camera the course");
|
||||
|
@ -182,88 +189,88 @@ void SaveConfigFile () {
|
|||
AddComment (liste, "rendered, resulting in slower performance. Decreasing this ");
|
||||
AddComment (liste, "value is an effective way to improve framerates.");
|
||||
AddIntItem (liste, "forward_clip_distance", param.forward_clip_distance);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Backward clipping distance");
|
||||
AddComment (liste, "Some objects aren't yet clipped to the view frustum, ");
|
||||
AddComment (liste, "so this value is used to control how far up the course these ");
|
||||
AddComment (liste, "objects are drawn.");
|
||||
AddIntItem (liste, "backward_clip_distance", param.backward_clip_distance);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Field of View of the camera");
|
||||
AddIntItem (liste, "fov", param.fov);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Bpp mode - bits per pixel [0...2]");
|
||||
AddComment (liste, "Controls the color depth of the OpenGL window");
|
||||
AddComment (liste, "0 = use current bpp setting of operating system,");
|
||||
AddComment (liste, "1 = 16 bpp, 2 = 32 bpp");
|
||||
AddIntItem (liste, "bpp_mode", param.bpp_mode);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Tree detail distance");
|
||||
AddComment (liste, "Controls how far up the course the trees are drawn crosswise.");
|
||||
AddIntItem (liste, "tree_detail_distance", param.tree_detail_distance);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Tux sphere divisions");
|
||||
AddComment (liste, "Controls how detailled the character is drawn");
|
||||
AddIntItem (liste, "tux_sphere_divisions", param.tux_sphere_divisions);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Tux shadow sphere divisions");
|
||||
AddComment (liste, "The same but for the shadow of the character");
|
||||
AddIntItem (liste, "tux_shadow_sphere_div", param.tux_shadow_sphere_divisions);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Detail level of the course");
|
||||
AddComment (liste, "This param is used for the quadtree and controls the");
|
||||
AddComment (liste, "LOD of the algorithm. ");
|
||||
AddIntItem (liste, "course_detail_level", param.course_detail_level);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Font type [0...2]");
|
||||
AddComment (liste, "0 = always arial-like font,");
|
||||
AddComment (liste, "1 = papercut font on the menu screens");
|
||||
AddComment (liste, "2 = papercut font for the hud display, too");
|
||||
AddIntItem (liste, "use_papercut_font", param.use_papercut_font);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Cursor type [0...1]");
|
||||
AddComment (liste, "0 = normal cursor (arrow), 1 = icicle");
|
||||
AddIntItem (liste, "ice_cursor", param.ice_cursor);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Draw full skybox [0...1]");
|
||||
AddComment (liste, "A normal skybox consists of 6 textures. In Tuxracer");
|
||||
AddComment (liste, "3 textures are invisible (top, bottom and back).");
|
||||
AddComment (liste, "These textures needn't be drawn.");
|
||||
AddIntItem (liste, "full_skybox", param.full_skybox);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Audio frequency");
|
||||
AddComment (liste, "Typical values are 11025, 22050 ...");
|
||||
AddIntItem (liste, "audio_freq", param.audio_freq);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Size of audio buffer");
|
||||
AddComment (liste, "Typical values are 512, 1024, 2048 ...");
|
||||
AddIntItem (liste, "audio_buffer_size", param.audio_buffer_size);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Select the music:");
|
||||
AddComment (liste, "(the racing music is defined by a music theme)");
|
||||
AddItem (liste, "menu_music", param.menu_music);
|
||||
AddItem (liste, "credits_music", param.credits_music);
|
||||
AddItem (liste, "config_music", param.config_music);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
AddComment (liste, "Use sqare root of scale factors for menu screens [0...1]");
|
||||
AddComment (liste, "Exprimental: these factors reduce the effect of screen scaling.");
|
||||
AddComment (liste, "The widgets are closer to their default sizes.");
|
||||
AddIntItem (liste, "use_quad_scale", param.use_quad_scale);
|
||||
liste.Add ("");
|
||||
liste.AddLine();
|
||||
|
||||
// ---------------------------------------
|
||||
liste.Save (param.configfile);
|
||||
|
@ -285,7 +292,7 @@ void InitConfig (const char *arg0) {
|
|||
if (strcmp (arg0, "./etr") == 0) { // start from work directory
|
||||
char *s = getcwd (buff, 256);
|
||||
if (s==NULL) {};
|
||||
} else { // start with full path
|
||||
} else { // start with full path
|
||||
strcpy (buff, arg0);
|
||||
if (strlen (buff) > 5) {
|
||||
buff[strlen(buff)-3] = 0;
|
||||
|
|
|
@ -45,6 +45,7 @@ struct TParam {
|
|||
// main config params:
|
||||
bool fullscreen;
|
||||
size_t res_type;
|
||||
uint32_t framerate;
|
||||
int perf_level;
|
||||
size_t language;
|
||||
int sound_volume;
|
||||
|
|
|
@ -48,9 +48,9 @@ bool CEvents::LoadEventList () {
|
|||
if (type == 0) {
|
||||
RaceList.push_back(TRace2());
|
||||
RaceList.back().race = SPStrN (line, "race", errorString);
|
||||
string item = SPStrN (line, "course", "");
|
||||
string item = SPStrN (line, "course");
|
||||
RaceList.back().course = Course.GetCourseIdx (item);
|
||||
item = SPStrN (line, "light", "");
|
||||
item = SPStrN (line, "light");
|
||||
RaceList.back().light = Env.GetLightIdx (item);
|
||||
RaceList.back().snow = SPIntN (line, "snow", 0);
|
||||
RaceList.back().wind = SPIntN (line, "wind", 0);
|
||||
|
@ -73,7 +73,7 @@ bool CEvents::LoadEventList () {
|
|||
int num = SPIntN (line, "num", 0);
|
||||
CupList.back().races.resize(num);
|
||||
for (int ii=0; ii<num; ii++) {
|
||||
string race = SPStrN (line, Int_StrN (ii+1), "");
|
||||
string race = SPStrN (line, Int_StrN (ii+1));
|
||||
CupList.back().races[ii] = &RaceList[GetRaceIdx(race)];
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ bool CEvents::LoadEventList () {
|
|||
int num = SPIntN (line, "num", 0);
|
||||
EventList.back().cups.resize(num);
|
||||
for (int ii=0; ii<num; ii++) {
|
||||
string cup = SPStrN (line, Int_StrN (ii+1), "");
|
||||
string cup = SPStrN (line, Int_StrN (ii+1));
|
||||
EventList.back().cups[ii] = &CupList[GetCupIdx(cup)];
|
||||
}
|
||||
}
|
||||
|
@ -206,8 +206,8 @@ bool CPlayers::LoadPlayers () {
|
|||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
plyr[i].name = SPStrN (line, "name", "unknown");
|
||||
plyr[i].funlocked = SPStrN (line, "unlocked", "");
|
||||
plyr[i].avatar = SPStrN (line, "avatar", "");
|
||||
plyr[i].funlocked = SPStrN (line, "unlocked");
|
||||
plyr[i].avatar = SPStrN (line, "avatar");
|
||||
plyr[i].texture = GetAvatarTexture(AvatarIndex[plyr[i].avatar]);
|
||||
plyr[i].ctrl = NULL;
|
||||
int active = SPIntN (line, "active", 0);
|
||||
|
@ -338,8 +338,8 @@ void CCharacter::LoadCharacterList () {
|
|||
CharList.resize(list.Count());
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
CharList[i].name = SPStrN (line, "name", "");
|
||||
CharList[i].dir = SPStrN (line, "dir", "");
|
||||
CharList[i].name = SPStrN (line, "name");
|
||||
CharList[i].dir = SPStrN (line, "dir");
|
||||
string typestr = SPStrN (line, "type", "unknown");
|
||||
CharList[i].type = SPIntN (char_type_index, typestr, -1);
|
||||
|
||||
|
|
|
@ -118,7 +118,6 @@ void CGameTypeSelect::Enter () {
|
|||
textbuttons[6] = AddTextButton (Trans.Text(5), CENTER, top + dist * 6, siz);
|
||||
|
||||
Music.Play (param.menu_music, -1);
|
||||
g_game.loopdelay = 10;
|
||||
}
|
||||
|
||||
void CGameTypeSelect::Loop (double time_step) {
|
||||
|
|
|
@ -90,7 +90,6 @@ void CIntro::Enter() {
|
|||
|
||||
Music.PlayTheme (g_game.theme_id, MUS_RACING);
|
||||
param.show_hud = true;
|
||||
g_game.loopdelay = 1;
|
||||
}
|
||||
|
||||
void CIntro::Loop (double time_step) {
|
||||
|
|
|
@ -60,7 +60,6 @@ void InitGame (int argc, char **argv) {
|
|||
g_game.force_treemap = 0;
|
||||
g_game.treesize = 3;
|
||||
g_game.treevar = 3;
|
||||
g_game.loopdelay = 1;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
|
|
@ -30,6 +30,7 @@ GNU General Public License for more details.
|
|||
#include "translation.h"
|
||||
#include "regist.h"
|
||||
#include "winsys.h"
|
||||
#include "spx.h"
|
||||
#include <cctype>
|
||||
|
||||
CNewPlayer NewPlayer;
|
||||
|
@ -103,7 +104,7 @@ void CNewPlayer::Enter() {
|
|||
double len = FT.GetTextWidth (Trans.Text(15));
|
||||
textbuttons[1] = AddTextButton (Trans.Text(15), area.right-len-50, AutoYPosN (70), siz);
|
||||
|
||||
textfield = AddTextField("", area.left, frametop, framewidth, frameheight);
|
||||
textfield = AddTextField(emptyString, area.left, frametop, framewidth, frameheight);
|
||||
}
|
||||
|
||||
void CNewPlayer::Loop(double timestep) {
|
||||
|
|
20
src/ogl.cpp
20
src/ogl.cpp
|
@ -69,12 +69,12 @@ void InitOpenglExtensions () {
|
|||
if (glLockArraysEXT_p != NULL && glUnlockArraysEXT_p != NULL) {
|
||||
|
||||
} else {
|
||||
Message ("GL_EXT_compiled_vertex_array extension NOT supported", "");
|
||||
Message ("GL_EXT_compiled_vertex_array extension NOT supported");
|
||||
glLockArraysEXT_p = NULL;
|
||||
glUnlockArraysEXT_p = NULL;
|
||||
}
|
||||
} else {
|
||||
Message ("No function available for obtaining GL proc addresses", "");
|
||||
Message ("No function available for obtaining GL proc addresses");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,20 +84,20 @@ void PrintGLInfo () {
|
|||
Message ("Gl renderer: ", (char*)glGetString (GL_RENDERER));
|
||||
Message ("Gl version: ", (char*)glGetString (GL_VERSION));
|
||||
string extensions = (char*)glGetString (GL_EXTENSIONS);
|
||||
Message ("", "");
|
||||
Message ("Gl extensions:", "");
|
||||
Message ("", "");
|
||||
Message ("");
|
||||
Message ("Gl extensions:");
|
||||
Message ("");
|
||||
|
||||
size_t oldpos = 0;
|
||||
size_t pos;
|
||||
while ((pos = extensions.find(' ', oldpos)) != string::npos) {
|
||||
string s = extensions.substr(oldpos, pos-oldpos);
|
||||
Message(s, "");
|
||||
Message(s);
|
||||
oldpos = pos+1;
|
||||
}
|
||||
Message(extensions.substr(oldpos), "");
|
||||
Message(extensions.substr(oldpos));
|
||||
|
||||
Message ("", "");
|
||||
Message ("");
|
||||
for (int i=0; i<(int)(sizeof(gl_values)/sizeof(gl_values[0])); i++) {
|
||||
switch (gl_values[i].type) {
|
||||
case GL_INT: {
|
||||
|
@ -122,7 +122,7 @@ void PrintGLInfo () {
|
|||
break;
|
||||
}
|
||||
default:
|
||||
Message ("", "");
|
||||
Message ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ void set_gl_options (TRenderMode mode) {
|
|||
break;
|
||||
|
||||
default:
|
||||
Message ("not a valid render mode", "");
|
||||
Message ("not a valid render mode");
|
||||
}
|
||||
}
|
||||
/* defined but not used
|
||||
|
|
|
@ -54,7 +54,6 @@ void COglTest::Keyb(unsigned int key, bool special, bool release, int x, int y)
|
|||
|
||||
void COglTest::Enter() {
|
||||
Winsys.KeyRepeat (true);
|
||||
g_game.loopdelay = 1;
|
||||
}
|
||||
|
||||
void COglTest::Loop(double timestep) {
|
||||
|
|
|
@ -331,7 +331,7 @@ void create_new_particles (const TVector3& loc, TVector3 vel, int num) {
|
|||
double speed = NormVector (vel);
|
||||
|
||||
if (particles.size() + num > MAX_PARTICLES) {
|
||||
Message ("maximum number of particles exceeded", "");
|
||||
Message ("maximum number of particles exceeded");
|
||||
}
|
||||
for (int i=0; i<num; i++) {
|
||||
particles.push_back(Particle());
|
||||
|
|
|
@ -509,7 +509,7 @@ void CControl::SolveOdeSystem (double timestep) {
|
|||
bool done = false;
|
||||
while (!done) {
|
||||
if (t >= tfinal) {
|
||||
Message ("t >= tfinal in ode_system()", "");
|
||||
Message ("t >= tfinal in ode_system()");
|
||||
break;
|
||||
}
|
||||
if (1.1 * h > tfinal - t) {
|
||||
|
|
|
@ -174,8 +174,6 @@ void CRaceSelect::Enter() {
|
|||
double len1 = FT.GetTextWidth (Trans.Text(13));
|
||||
textbuttons[0] = AddTextButton (Trans.Text(13), area.right-len1-50, AutoYPosN (80), siz);
|
||||
textbuttons[1] = AddTextButton (Trans.Text(8), area.left + 50, AutoYPosN (80), siz);
|
||||
|
||||
g_game.loopdelay = 20;
|
||||
}
|
||||
|
||||
void CRaceSelect::Loop(double timestep) {
|
||||
|
|
|
@ -104,7 +104,6 @@ void CRegist::Enter (void) {
|
|||
textbuttons[0] = AddTextButton (Trans.Text(60), CENTER, AutoYPosN (62), siz);
|
||||
textbuttons[1] = AddTextButton (Trans.Text(61), CENTER, AutoYPosN (70), siz);
|
||||
|
||||
g_game.loopdelay = 10;
|
||||
if (Char.CharList.empty())
|
||||
Winsys.Terminate(); // Characters are necessary - ETR is unusable otherwise
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ void CSplashScreen::Enter() {
|
|||
Winsys.ShowCursor (!param.ice_cursor);
|
||||
init_ui_snow ();
|
||||
Music.Play (param.menu_music, -1);
|
||||
g_game.loopdelay = 10;
|
||||
}
|
||||
|
||||
void CSplashScreen::Loop(double timestep) {
|
||||
|
|
12
src/spx.cpp
12
src/spx.cpp
|
@ -407,6 +407,12 @@ void CSPList::Add (const string& line) {
|
|||
}
|
||||
}
|
||||
|
||||
void CSPList::AddLine () {
|
||||
if (flines.size() < fmax) {
|
||||
flines.push_back(emptyString);
|
||||
}
|
||||
}
|
||||
|
||||
void CSPList::Append (const string& line, size_t idx) {
|
||||
if (idx >= flines.size()) return;
|
||||
flines[idx] += line;
|
||||
|
@ -422,7 +428,7 @@ bool CSPList::Load (const string &filepath) {
|
|||
string line;
|
||||
|
||||
if (!tempfile) {
|
||||
Message ("CSPList::Load - unable to open " + filepath, "");
|
||||
Message ("CSPList::Load - unable to open " + filepath);
|
||||
return false;
|
||||
} else {
|
||||
bool backflag = false;
|
||||
|
@ -456,7 +462,7 @@ bool CSPList::Load (const string &filepath) {
|
|||
backflag = fwdflag;
|
||||
}
|
||||
} else {
|
||||
Message ("CSPList::Load - not enough lines","");
|
||||
Message ("CSPList::Load - not enough lines");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +478,7 @@ bool CSPList::Load (const string& dir, const string& filename) {
|
|||
bool CSPList::Save (const string &filepath) const {
|
||||
std::ofstream tempfile(filepath.c_str());
|
||||
if (!tempfile) {
|
||||
Message ("CSPList::Save - unable to open " + filepath, "");
|
||||
Message ("CSPList::Save - unable to open " + filepath);
|
||||
return false;
|
||||
} else {
|
||||
for (size_t i=0; i<flines.size(); i++) {
|
||||
|
|
|
@ -24,6 +24,9 @@ GNU General Public License for more details.
|
|||
|
||||
using namespace std;
|
||||
|
||||
extern const string emptyString;
|
||||
extern const string errorString;
|
||||
|
||||
// ----- elementary string functions ----------------------------------
|
||||
string MakePathStr (const string& src, const string& add);
|
||||
void SInsertN (string &s, size_t pos, const string& ins);
|
||||
|
@ -57,7 +60,7 @@ bool SPExistsN (const string &s, const string &tag);
|
|||
size_t SPPosN (const string &s, const string &tag);
|
||||
|
||||
string SPItemN (const string &s, const string &tag);
|
||||
string SPStrN (const string &s, const string &tag, const string& def);
|
||||
string SPStrN (const string &s, const string &tag, const string& def = emptyString);
|
||||
int SPIntN (const string &s, const string &tag, const int def);
|
||||
bool SPBoolN (const string &s, const string &tag, const bool def);
|
||||
float SPFloatN (const string &s, const string &tag, const float def);
|
||||
|
@ -100,6 +103,7 @@ public:
|
|||
size_t Count () const { return flines.size(); }
|
||||
void Clear () { flines.clear(); }
|
||||
void Add (const string& line);
|
||||
void AddLine();
|
||||
void Append (const string& line, size_t idx);
|
||||
void Print () const;
|
||||
bool Load (const string &filepath);
|
||||
|
@ -110,7 +114,4 @@ public:
|
|||
void MakeIndex (map<string, size_t>& index, const string &tag);
|
||||
};
|
||||
|
||||
extern const string emptyString;
|
||||
extern const string errorString;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,7 @@ GNU General Public License for more details.
|
|||
#include "states.h"
|
||||
#include "ogl.h"
|
||||
#include "winsys.h"
|
||||
#include <ctime>
|
||||
|
||||
State::Manager State::manager(Winsys);
|
||||
|
||||
|
@ -33,12 +34,19 @@ State::Manager::~Manager() {
|
|||
void State::Manager::Run(State& entranceState) {
|
||||
current = &entranceState;
|
||||
current->Enter();
|
||||
clock_t ticks = clock();
|
||||
while (!quit) {
|
||||
PollEvent();
|
||||
if (next)
|
||||
EnterNextState();
|
||||
CallLoopFunction();
|
||||
SDL_Delay(g_game.loopdelay);
|
||||
if (param.framerate != 0) {
|
||||
clock_t nticks = clock();
|
||||
int32_t sleeptime = CLOCKS_PER_SEC/param.framerate - (nticks-ticks);
|
||||
if (sleeptime > 0)
|
||||
SDL_Delay(sleeptime);
|
||||
ticks = nticks;
|
||||
}
|
||||
}
|
||||
current->Exit();
|
||||
previous = current;
|
||||
|
|
|
@ -516,10 +516,10 @@ void CTexture::LoadTextureList () {
|
|||
if (list.Load (param.tex_dir, "textures.lst")) {
|
||||
for (size_t i=0; i<list.Count(); i++) {
|
||||
const string& line = list.Line(i);
|
||||
string name = SPStrN (line, "name", "");
|
||||
string name = SPStrN (line, "name");
|
||||
int id = SPIntN (line, "id", -1);
|
||||
CommonTex.resize(max(CommonTex.size(), (size_t)id+1));
|
||||
string texfile = SPStrN (line, "file", "");
|
||||
string texfile = SPStrN (line, "file");
|
||||
bool rep = SPBoolN (line, "repeat", false);
|
||||
if (id >= 0) {
|
||||
CommonTex[id] = new TTexture();
|
||||
|
|
|
@ -232,7 +232,6 @@ void CTools::Enter() {
|
|||
InitFrameTools ();
|
||||
|
||||
Winsys.KeyRepeat (true);
|
||||
g_game.loopdelay = 1;
|
||||
}
|
||||
|
||||
void CTools::Keyb(unsigned int key, bool special, bool release, int x, int y) {
|
||||
|
|
16
src/tux.cpp
16
src/tux.cpp
|
@ -449,16 +449,16 @@ bool CCharShape::Load (const string& dir, const string& filename, bool with_acti
|
|||
const string& line = list.Line(i);
|
||||
int node_name = SPIntN (line, "node", -1);
|
||||
int parent_name = SPIntN (line, "par", -1);
|
||||
string mat_name = SPStrN (line, "mat", "");
|
||||
string name = SPStrN (line, "joint", "");
|
||||
string fullname = SPStrN (line, "name", "");
|
||||
string mat_name = SPStrN (line, "mat");
|
||||
string name = SPStrN (line, "joint");
|
||||
string fullname = SPStrN (line, "name");
|
||||
|
||||
if (SPIntN (line, "material", 0) > 0) {
|
||||
CreateMaterial (line);
|
||||
} else {
|
||||
double visible = SPFloatN (line, "vis", -1.0);
|
||||
bool shadow = SPBoolN (line, "shad", false);
|
||||
string order = SPStrN (line, "order", "");
|
||||
string order = SPStrN (line, "order");
|
||||
CreateCharNode (parent_name, node_name, name, fullname, order, shadow);
|
||||
TVector3 rot = SPVector3N (line, "rot", NullVec);
|
||||
MaterialNode (node_name, mat_name);
|
||||
|
@ -781,7 +781,7 @@ void CCharShape::DrawShadow () {
|
|||
|
||||
TCharNode *node = GetNode(0);
|
||||
if (node == NULL) {
|
||||
Message ("couldn't find tux's root node", "");
|
||||
Message ("couldn't find tux's root node");
|
||||
return;
|
||||
}
|
||||
TraverseDagForShadow (node, model_matrix);
|
||||
|
@ -922,13 +922,13 @@ void CCharShape::SaveCharNodes (const string& dir, const string& filename) {
|
|||
CSPList list (MAX_CHAR_NODES + 10);
|
||||
|
||||
list.Add ("# Generated by Tuxracer tools");
|
||||
list.Add ("");
|
||||
list.AddLine ();
|
||||
if (!Materials.empty()) {
|
||||
list.Add ("# Materials:");
|
||||
for (size_t i=0; i<Materials.size(); i++)
|
||||
if (!Materials[i].matline.empty())
|
||||
list.Add (Materials[i].matline);
|
||||
list.Add ("");
|
||||
list.AddLine ();
|
||||
}
|
||||
|
||||
list.Add ("# Nodes:");
|
||||
|
@ -982,7 +982,7 @@ void CCharShape::SaveCharNodes (const string& dir, const string& filename) {
|
|||
|
||||
list.Add (line);
|
||||
if (i<numNodes-3) {
|
||||
if (node->visible && !Nodes[i+1]->visible) list.Add ("");
|
||||
if (node->visible && !Nodes[i+1]->visible) list.AddLine ();
|
||||
const string& joint = Nodes[i+2]->joint;
|
||||
if (joint.empty()) list.Add ("# " + joint);
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ void update_view (CControl *ctrl, double dt) {
|
|||
}
|
||||
|
||||
default:
|
||||
Message ("code not reached", "");
|
||||
Message ("code not reached");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue