You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(136) |
Dec
(218) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(214) |
Feb
(208) |
Mar
(186) |
Apr
(15) |
May
(3) |
Jun
(35) |
Jul
(6) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(58) |
Aug
(123) |
Sep
(31) |
Oct
(9) |
Nov
|
Dec
(1) |
2006 |
Jan
(25) |
Feb
(10) |
Mar
(25) |
Apr
(61) |
May
|
Jun
(78) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
(12) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <geo...@us...> - 2003-12-22 10:29:47
|
Update of /cvsroot/timewarp/source/other In directory sc8-pr-cvs1:/tmp/cvs-serv12007/other Modified Files: shippart.cpp shippart.h Log Message: putting the "targets" into a separate class (instead of being part of Game) Index: shippart.cpp =================================================================== RCS file: /cvsroot/timewarp/source/other/shippart.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** shippart.cpp 20 Oct 2003 11:00:19 -0000 1.7 --- shippart.cpp 22 Dec 2003 10:29:44 -0000 1.8 *************** *** 13,53 **** - // perhaps this should be a Game routine... - - bool isintargetlist(SpaceObject *o) - { - STACKTRACE - - int i; - - for (i = 0; i < game->num_targets; i += 1) - { - if (game->target[i] == o) - { - return true; - } - } - - return false; - } - - /* - void removefromtargetlist(SpaceObject *o) - { - int i; - - for (i = 0; i < game->num_targets; i += 1) - { - if (game->target[i] == o) - { - game->num_targets -= 1; - game->target[i] = game->target[game->num_targets]; - break; - } - } - } - */ - - --- 13,16 ---- *************** *** 71,77 **** // make sure the "ship" is not a real target ! if (isintargetlist(this)) //removefromtargetlist(this); ! game->rem_target(this); Ship::calculate(); --- 34,40 ---- // make sure the "ship" is not a real target ! if (targets->isintargetlist(this)) //removefromtargetlist(this); ! targets->rem(this); Ship::calculate(); *************** *** 177,181 **** collider = 0; ! game->add_target(this); } --- 140,144 ---- collider = 0; ! targets->add(this); } Index: shippart.h =================================================================== RCS file: /cvsroot/timewarp/source/other/shippart.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** shippart.h 20 Oct 2003 11:00:19 -0000 1.5 --- shippart.h 22 Dec 2003 10:29:44 -0000 1.6 *************** *** 6,10 **** //void removefromtargetlist(SpaceObject *o); ! bool isintargetlist(SpaceObject *o); --- 6,10 ---- //void removefromtargetlist(SpaceObject *o); ! //bool isintargetlist(SpaceObject *o); |
From: <geo...@us...> - 2003-12-22 10:29:47
|
Update of /cvsroot/timewarp/source/melee In directory sc8-pr-cvs1:/tmp/cvs-serv12007/melee Modified Files: mcontrol.cpp mgame.cpp mgame.h mship.cpp Added Files: mtarget.cpp mtarget.h Log Message: putting the "targets" into a separate class (instead of being part of Game) --- NEW FILE: mtarget.cpp --- #include "mtarget.h" Targets *targets; Targets::Targets() { N = 0; item = 0; } Targets::~Targets() { reset(); } void Targets::reset() { if (item) free(item); item = 0; N = 0; } void Targets::add(SpaceObject *a) {STACKTRACE N += 1; item = (SpaceObject **) realloc(item, sizeof(SpaceObject *) * N); item[N - 1] = a; a->attributes |= ATTRIB_TARGET; } void Targets::rem(int i) { -- N; item[i]->attributes &= ~ATTRIB_TARGET; item[i] = item[N]; } void Targets::rem(SpaceObject *r) { int i; for ( i = 0; i < N; ++i ) if (item[i] == r) break; if (i == N) return; rem(i); } void Targets::calculate() { int i; for (i = 0; i < N; i += 1) { if (!item[i]->exists()) { rem(i); -- i; } } } int Targets::findindex(SpaceObject *o) { int i; for (i = 0; i < N; i += 1) { if (item[i] == o) { return i; } } return -1; } bool Targets::isintargetlist(SpaceObject *o) { return findindex(o) >= 0; } --- NEW FILE: mtarget.h --- #ifndef _MTARGET_H_ #define _MTARGET_H_ #include "../melee.h" #include "mframe.h" class Targets { public: Targets(); virtual ~Targets(); int N; SpaceObject **item; virtual void add (SpaceObject *a); virtual void rem(int i); virtual void rem(SpaceObject *r); virtual void calculate(); virtual void reset(); int findindex(SpaceObject *o); bool isintargetlist(SpaceObject *o); }; extern Targets *targets; #endif Index: mcontrol.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mcontrol.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mcontrol.cpp 12 Dec 2003 00:15:43 -0000 1.12 --- mcontrol.cpp 22 Dec 2003 10:29:44 -0000 1.13 *************** *** 310,314 **** void Control::set_target(int i) { STACKTRACE; ! if (i >= game->num_targets) {tw_error("oscar hamburger!!!!!!!!!");} if (i == -1) { index = i; --- 310,314 ---- void Control::set_target(int i) { STACKTRACE; ! if (i >= targets->N) {tw_error("oscar hamburger!!!!!!!!!");} if (i == -1) { index = i; *************** *** 316,329 **** return; } ! if (!valid_target(game->target[i])) {tw_error("oscer hambuger");} index = i; ! target = game->target[index]; return; } void Control::target_stuff() {STACKTRACE if (index == -1) { ! if (game->num_targets) { ! index = random() % game->num_targets; ! target = game->target[index]; goto validate; } --- 316,329 ---- return; } ! if (!valid_target(targets->item[i])) {tw_error("oscer hambuger");} index = i; ! target = targets->item[index]; return; } void Control::target_stuff() {STACKTRACE if (index == -1) { ! if (targets->N) { ! index = random() % targets->N; ! target = targets->item[index]; goto validate; } *************** *** 333,338 **** } blah: ! if (index >= game->num_targets) { ! if (game->num_targets) { index -= 1; if (index < 0) index = 0; --- 333,338 ---- } blah: ! if (index >= targets->N) { ! if (targets->N) { index -= 1; if (index < 0) index = 0; *************** *** 345,349 **** } } ! if (target == game->target[index]) { goto done; } --- 345,349 ---- } } ! if (target == targets->item[index]) { goto done; } *************** *** 352,357 **** int o; o = index; ! for (index = 0; index < game->num_targets; index += 1) { ! if (game->target[index] == target) { goto done; } --- 352,357 ---- int o; o = index; ! for (index = 0; index < targets->N; index += 1) { ! if (targets->item[index] == target) { goto done; } *************** *** 364,369 **** int start; start = index; ! while (!valid_target(game->target[index])) { ! index = (index + 1) % game->num_targets; if (index == start) { index = -1; --- 364,369 ---- int start; start = index; ! while (!valid_target(targets->item[index])) { ! index = (index + 1) % targets->N; if (index == start) { index = -1; *************** *** 372,376 **** } } ! target = game->target[index]; change: done: --- 372,376 ---- } } ! target = targets->item[index]; change: done: *************** *** 493,497 **** if (!target || target->isInvisible()) return; if (!(attributes & ATTRIB_ACTIVE_FOCUS)) return; ! if (game->num_targets < 3) return; if (target_sign_color == 255) return; --- 493,497 ---- if (!target || target->isInvisible()) return; if (!(attributes & ATTRIB_ACTIVE_FOCUS)) return; ! if (targets->N < 3) return; if (target_sign_color == 255) return; Index: mgame.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mgame.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** mgame.cpp 12 Dec 2003 00:15:43 -0000 1.25 --- mgame.cpp 22 Dec 2003 10:29:44 -0000 1.26 *************** *** 213,237 **** } - void Game::add_target(SpaceObject *new_target) {STACKTRACE - num_targets += 1; - target = (SpaceObject **) realloc(target, sizeof(SpaceObject *) * num_targets); - target[num_targets - 1] = new_target; - new_target->attributes |= ATTRIB_TARGET; - } - - void Game::rem_target(SpaceObject *r) - { - int i; - for ( i = 0; i < num_targets; ++i ) - if (target[i] == r) - break; - - if (i == num_targets) - return; - - target[i]->attributes &= ~ATTRIB_TARGET; - target[i] = target[num_targets-1]; - -- num_targets; - } void Game::prepare() { --- 213,216 ---- *************** *** 243,246 **** --- 222,226 ---- Physics::prepare(); ::game = this; + ::targets = &gametargets; return; } *************** *** 282,286 **** if (c) c->select_ship(s, id); ! add_target(s); s->attributes |= ATTRIB_NOTIFY_ON_DEATH; return s; --- 262,266 ---- if (c) c->select_ship(s, id); ! gametargets.add(s); s->attributes |= ATTRIB_NOTIFY_ON_DEATH; return s; *************** *** 688,698 **** if (active_focus_destroyed && (focus_index >= 0)) focus[focus_index]->attributes |= ATTRIB_ACTIVE_FOCUS; ! for (i = 0; i < num_targets; i += 1) { ! if (!target[i]->exists()) { ! num_targets -= 1; ! target[i] = target[num_targets]; ! i -= 1; ! } ! } --- 668,673 ---- if (active_focus_destroyed && (focus_index >= 0)) focus[focus_index]->attributes |= ATTRIB_ACTIVE_FOCUS; ! ! gametargets.calculate(); *************** *** 851,856 **** focus_index = 0; focus = NULL; ! num_targets = 0; ! target = NULL; view = NULL; window = NULL; --- 826,832 ---- focus_index = 0; focus = NULL; ! // num_targets = 0; ! // target = NULL; ! gametargets.reset(); view = NULL; window = NULL; Index: mgame.h =================================================================== RCS file: /cvsroot/timewarp/source/melee/mgame.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mgame.h 19 Dec 2003 23:33:35 -0000 1.11 --- mgame.h 22 Dec 2003 10:29:44 -0000 1.12 *************** *** 6,9 **** --- 6,11 ---- #define _MGAME_H + #include "mtarget.h" + extern int random_seed[2]; extern int interpolate_frames; *************** *** 146,156 **** virtual void add_focus (Presence *focus, int channel = -1); ! int num_targets; ! SpaceObject **target; ! virtual void add_target (SpaceObject *target); ! ! virtual void rem_target(SpaceObject *r); ! ! --- 148,152 ---- virtual void add_focus (Presence *focus, int channel = -1); ! Targets gametargets; Index: mship.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mship.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** mship.cpp 24 Nov 2003 22:13:24 -0000 1.21 --- mship.cpp 22 Dec 2003 10:29:44 -0000 1.22 *************** *** 585,594 **** if (target_pressed && (!target_pressed_prev) && control) { if (target_next) { ! if (control && game->num_targets) { i = control->index; if (i < 0) i = 0; while (1) { ! i = (i + 1) % game->num_targets; ! if (control->valid_target(game->target[i])) { control->set_target(i); break; --- 585,594 ---- if (target_pressed && (!target_pressed_prev) && control) { if (target_next) { ! if (control && targets->N) { i = control->index; if (i < 0) i = 0; while (1) { ! i = (i + 1) % targets->N; ! if (control->valid_target(targets->item[i])) { control->set_target(i); break; *************** *** 604,613 **** } else if (target_prev) { ! if (control && game->num_targets) { i = control->index; if (i < 0) i = 0; while (1) { ! i = (i + game->num_targets - 1) % game->num_targets; ! if (control->valid_target(game->target[i])) { control->set_target(i); break; --- 604,613 ---- } else if (target_prev) { ! if (control && targets->N) { i = control->index; if (i < 0) i = 0; while (1) { ! i = (i + targets->N - 1) % targets->N; ! if (control->valid_target(targets->item[i])) { control->set_target(i); break; *************** *** 624,634 **** } else if (target_closest) { ! if (control && game->num_targets) { int i, j = -1; double r = 99999; double d; ! for (i = 0; i < game->num_targets; i += 1) { ! if (control->valid_target(game->target[i])) { ! d = distance(game->target[i]); if (d < r) { r = d; --- 624,634 ---- } else if (target_closest) { ! if (control && targets->N) { int i, j = -1; double r = 99999; double d; ! for (i = 0; i < targets->N; i += 1) { ! if (control->valid_target(targets->item[i])) { ! d = distance(targets->item[i]); if (d < r) { r = d; |
From: <geo...@us...> - 2003-12-22 10:29:47
|
Update of /cvsroot/timewarp/source/games In directory sc8-pr-cvs1:/tmp/cvs-serv12007/games Modified Files: gflmelee.cpp gmissions.cpp gsamp2.cpp gsample.cpp gsarena.cpp vanguard.cpp Log Message: putting the "targets" into a separate class (instead of being part of Game) Index: gflmelee.cpp =================================================================== RCS file: /cvsroot/timewarp/source/games/gflmelee.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** gflmelee.cpp 14 Dec 2003 00:51:59 -0000 1.16 --- gflmelee.cpp 22 Dec 2003 10:29:44 -0000 1.17 *************** *** 800,806 **** ssize = Vector2(30,30); ! for ( int itarget = 0; itarget < num_targets; ++itarget ) { ! SpaceObject *o = game->target[itarget]; if ( o->isShip() ) --- 800,806 ---- ssize = Vector2(30,30); ! for ( int itarget = 0; itarget < gametargets.N; ++itarget ) { ! SpaceObject *o = gametargets.item[itarget]; if ( o->isShip() ) *************** *** 981,987 **** c->state = 1; ! for ( int itarget = 0; itarget < num_targets; ++itarget ) { ! SpaceObject *o = game->target[itarget]; if ( o->isShip() && o != c->ship && is_in_team(o, alliance[iplayer]) ) --- 981,987 ---- c->state = 1; ! for ( int itarget = 0; itarget < gametargets.N; ++itarget ) { ! SpaceObject *o = gametargets.item[itarget]; if ( o->isShip() && o != c->ship && is_in_team(o, alliance[iplayer]) ) *************** *** 1026,1032 **** // choose a new target ! int i; ! for ( i = 0; i < num_targets; ++i ) { ! if (c->valid_target(game->target[i])) { c->set_target(i); --- 1026,1032 ---- // choose a new target ! int i; ! for ( i = 0; i < gametargets.N; ++i ) { ! if (c->valid_target(gametargets.item[i])) { c->set_target(i); *************** *** 1089,1093 **** itarget = 0; ! while ( game->target[itarget] != c->ship && itarget < num_targets-1 ) ++itarget; --- 1089,1093 ---- itarget = 0; ! while ( gametargets.item[itarget] != c->ship && itarget < gametargets.N-1 ) ++itarget; *************** *** 1099,1108 **** { ! if ( itarget > num_targets-1 ) ! itarget -= num_targets; if ( itarget < 0 ) ! itarget += num_targets; ! SpaceObject *o = game->target[itarget]; // Control *c = playercontrols[0]; // is already done earlier --- 1099,1108 ---- { ! if ( itarget > gametargets.N-1 ) ! itarget -= gametargets.N; if ( itarget < 0 ) ! itarget += gametargets.N; ! SpaceObject *o = targets->item[itarget]; // Control *c = playercontrols[0]; // is already done earlier Index: gmissions.cpp =================================================================== RCS file: /cvsroot/timewarp/source/games/gmissions.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** gmissions.cpp 13 Dec 2003 14:30:32 -0000 1.19 --- gmissions.cpp 22 Dec 2003 10:29:44 -0000 1.20 *************** *** 1160,1167 **** count = 0; ! for ( i = 0; i < num_targets; ++i ) { ! if (target[i] && target[i]->get_team() == team_badguys ) ! if (target[i]->ship && target[i]->ship->crew > 0) ++count; } --- 1160,1167 ---- count = 0; ! for ( i = 0; i < gametargets.N; ++i ) { ! if (gametargets.item[i] && gametargets.item[i]->get_team() == team_badguys ) ! if (gametargets.item[i]->ship && gametargets.item[i]->ship->crew > 0) ++count; } *************** *** 1446,1453 **** // check all ships with that name, and set their target ! int i; ! for ( i = 0; i < num_targets; ++i ) { SpaceObject *s; ! s = target[i]; if (s->get_team() == team) s->target = t; // now they should go and attack t ?! --- 1446,1453 ---- // check all ships with that name, and set their target ! int i; ! for ( i = 0; i < gametargets.N; ++i ) { SpaceObject *s; ! s = gametargets.item[i]; if (s->get_team() == team) s->target = t; // now they should go and attack t ?! *************** *** 1890,1894 **** team_badguys); add( factory ); ! add_target(factory); // so that UQ fighters (and homingmissiles?) also see it as a target. add(new HealthBar(factory, &healthtoggle)); --- 1890,1894 ---- team_badguys); add( factory ); ! gametargets.add(factory); // so that UQ fighters (and homingmissiles?) also see it as a target. add(new HealthBar(factory, &healthtoggle)); Index: gsamp2.cpp =================================================================== RCS file: /cvsroot/timewarp/source/games/gsamp2.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gsamp2.cpp 25 Oct 2003 14:30:19 -0000 1.5 --- gsamp2.cpp 22 Dec 2003 10:29:44 -0000 1.6 *************** *** 194,198 **** add ( starbase ); starbase->change_owner ( ship ); ! add_target (starbase); time_for_next_attack = game_time + 3 * 1000;//first attack in 3 seconds from now --- 194,198 ---- add ( starbase ); starbase->change_owner ( ship ); ! gametargets.add (starbase); time_for_next_attack = game_time + 3 * 1000;//first attack in 3 seconds from now Index: gsample.cpp =================================================================== RCS file: /cvsroot/timewarp/source/games/gsample.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gsample.cpp 26 Oct 2003 10:43:17 -0000 1.6 --- gsample.cpp 22 Dec 2003 10:29:44 -0000 1.7 *************** *** 320,326 **** if (respawn_time == -1) { int i, humans = 0, enemies = 0; ! for (i = 0; i < num_targets; i += 1) { ! if (target[i]->get_team() == human_team) humans += 1; ! if (target[i]->get_team() == enemy_team) enemies += 1; } //if either team has no targetable items remaining (generally ships), pick new ships --- 320,326 ---- if (respawn_time == -1) { int i, humans = 0, enemies = 0; ! for (i = 0; i < gametargets.N; i += 1) { ! if (gametargets.item[i]->get_team() == human_team) humans += 1; ! if (gametargets.item[i]->get_team() == enemy_team) enemies += 1; } //if either team has no targetable items remaining (generally ships), pick new ships Index: gsarena.cpp =================================================================== RCS file: /cvsroot/timewarp/source/games/gsarena.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gsarena.cpp 25 Oct 2003 14:30:19 -0000 1.7 --- gsarena.cpp 22 Dec 2003 10:29:44 -0000 1.8 *************** *** 46,58 **** // int i, humans = 0, enemies = 0; int i, t1=0, t2=0, t3=0, t4=0, t5=0, t6=0, t7=0, t8=0; ! for (i = 0; i < num_targets; i += 1) { ! if (target[i]->get_team() == team[1]) t1 += 1; ! if (target[i]->get_team() == team[2]) t2 += 1; ! if (target[i]->get_team() == team[3]) t3 += 1; ! if (target[i]->get_team() == team[4]) t4 += 1; ! if (target[i]->get_team() == team[5]) t5 += 1; ! if (target[i]->get_team() == team[6]) t6 += 1; ! if (target[i]->get_team() == team[7]) t7 += 1; ! if (target[i]->get_team() == team[8]) t8 += 1; } //if either team has no targetable items remaining (generally ships), pick new ships --- 46,61 ---- // int i, humans = 0, enemies = 0; int i, t1=0, t2=0, t3=0, t4=0, t5=0, t6=0, t7=0, t8=0; ! for (i = 0; i < gametargets.N; i += 1) ! { ! SpaceObject *o = gametargets.item[i]; ! ! if (o->get_team() == team[1]) t1 += 1; ! if (o->get_team() == team[2]) t2 += 1; ! if (o->get_team() == team[3]) t3 += 1; ! if (o->get_team() == team[4]) t4 += 1; ! if (o->get_team() == team[5]) t5 += 1; ! if (o->get_team() == team[6]) t6 += 1; ! if (o->get_team() == team[7]) t7 += 1; ! if (o->get_team() == team[8]) t8 += 1; } //if either team has no targetable items remaining (generally ships), pick new ships *************** *** 76,82 **** if ( (died[num]!=1) && (!s[num]->exists()) ) { message.print( 4000, 4000, "Team %d starbase was destroyed", num+1 ); //("Player's 1 Starbase was destroyed", 3000); ! for (i = 0; i < num_targets; i += 1) { ! if (target[i]->get_team() == team[num]) { ! target[i]->handle_damage(NULL, 0, 999); //target[i]->handle_damage(target[i]); } --- 79,85 ---- if ( (died[num]!=1) && (!s[num]->exists()) ) { message.print( 4000, 4000, "Team %d starbase was destroyed", num+1 ); //("Player's 1 Starbase was destroyed", 3000); ! for (i = 0; i < gametargets.N; i += 1) { ! if (gametargets.item[i]->get_team() == team[num]) { ! gametargets.item[i]->handle_damage(NULL, 0, 999); //target[i]->handle_damage(target[i]); } Index: vanguard.cpp =================================================================== RCS file: /cvsroot/timewarp/source/games/vanguard.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** vanguard.cpp 25 Oct 2003 14:30:19 -0000 1.9 --- vanguard.cpp 22 Dec 2003 10:29:44 -0000 1.10 *************** *** 483,489 **** if (respawn_time == -1) { int i, humans = 0, enemies = 0; ! for (i = 0; i < num_targets; i += 1) { ! if (target[i]->get_team() == human_team) humans += 1; ! if (target[i]->get_team() == enemy_team) enemies += 1; } //if either team has no targetable items remaining (generally ships), pick new ships --- 483,489 ---- if (respawn_time == -1) { int i, humans = 0, enemies = 0; ! for (i = 0; i < gametargets.N; i += 1) { ! if (gametargets.item[i]->get_team() == human_team) humans += 1; ! if (gametargets.item[i]->get_team() == enemy_team) enemies += 1; } //if either team has no targetable items remaining (generally ships), pick new ships |
Update of /cvsroot/timewarp/source/gamex In directory sc8-pr-cvs1:/tmp/cvs-serv3063/gamex Modified Files: gamedata.cpp gamedata.h gamegeneral.cpp gamehyper.cpp gamehyper.h gamemelee.cpp gamemelee.h gameplanetview.cpp gamestarmap.cpp projectx.cpp Log Message: adding race information Index: gamedata.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamedata.cpp 19 Dec 2003 23:33:35 -0000 1.4 --- gamedata.cpp 22 Dec 2003 09:37:08 -0000 1.5 *************** *** 6,9 **** --- 6,12 ---- REGISTER_FILE + #include "../frame.h" + #include "../melee/mview.h" + #include "gamedata.h" *************** *** 16,19 **** --- 19,24 ---- PlayerInfo playerinfo; MapEverything mapeverything; + RaceManager racelist; + *************** *** 216,219 **** --- 221,225 ---- } + scalepos = 1; } *************** *** 363,364 **** --- 369,712 ---- return i; // a match } + + + + + + + + + + + + + Patrol::Patrol() + { + // default to a single system-fleet (and no hyperspace patrol fleets, and no capital (special) fleet) + numhyperfleets = 0; + numsystemfleets = 1; + numcapitalfleets = 0; + + range = 0; + } + + + + + RaceSettlement::RaceSettlement(RaceInfo *arace) + { + next = 0; + + race = arace; + + istar = 0; + iplanet = 0; + imoon = 0; + } + + RaceSettlement::~RaceSettlement() + { + } + + void RaceSettlement::locate(int astar, int aplanet, int amoon) + { + istar = astar; + iplanet = aplanet; + imoon = amoon; + } + + void RaceSettlement::calculate() + { + } + + void RaceSettlement::animate_starmap(Frame *f) + { + if (!patrol.range) + return; + + BITMAP *bmp = f->surface; + + // in case of the starmap, show the circles of influence + + int R; + Vector2 P; + + P = corner(mapeverything.region[0]->sub[istar]->position * mapeverything.region[0]->scalepos); + + R = patrol.range * mapeverything.region[0]->scalepos * space_zoom; + + //void circlefill(BITMAP *bmp, int x, int y, int radius, int color); + circlefill(bmp, P.x, P.y, R, race->color); + } + + + + + + + RaceColony::RaceColony(RaceInfo *arace) + : + RaceSettlement(arace) + { + // this is a default colony of 10 K individuals (1 million). + population = 10; + + population *= race->cinfo.start_population_multiplier; + + calculate(); + } + + + void RaceColony::calculate() + { + double dt = frame_time * 1E-3; + + // growth ? + population *= exp(log(2.0) * dt / race->cinfo.doubling_period); + + patrol.range = 20 + sqrt(population / 100); + + if (patrol.range > 100) + patrol.range = 100; + + patrol.numsystemfleets = population / 10; + patrol.numhyperfleets = population / 1E3; + patrol.numcapitalfleets = population / 1E6; + } + + + + + + + + + + RaceInfo::RaceInfo(char *arace_id, int acolor) + { + next = 0; + + firstcol = 0; + lastcol = 0; + + id = new char [strlen(arace_id)+1]; + strcpy(id, arace_id); + + color = acolor; + + strcpy(cinfo.env_type, "gaia"); + cinfo.doubling_period = 10.0; // 10 years to double the population + cinfo.start_population_multiplier = 1.0; + } + + + RaceInfo::~RaceInfo() + { + delete id; + } + + + void RaceInfo::calculate() + { + } + + + + void RaceInfo::add(RaceColony *rc) + { + if (!firstcol) + firstcol = rc; + + if (lastcol) + lastcol->next = rc; + + lastcol = rc; + + } + + void RaceInfo::init_colonies(char *ininame) + { + set_config_file(ininame); + + // init colonies + + int i, N; + N = get_config_int(0, "N", 0); + + for ( i = 0; i < N; ++i ) + { + RaceColony *rc; + rc = new RaceColony(this); + add(rc); + + char colid[64]; + sprintf(colid, "colony%03i", i); + + int istar, iplan, imoon; + istar = get_config_int(colid, "star", 0); + iplan = get_config_int(colid, "planet", 0); + imoon = get_config_int(colid, "moon", 0); + rc->locate(istar, iplan, imoon); + + rc->population = get_config_float(colid, "population", 0); + + rc->calculate(); + } + } + + + void RaceInfo::animate_starmap(Frame *f) + { + RaceSettlement *current; + current = firstcol; + + while (current) + { + current->animate_starmap(f); + current = current->next; + } + } + + + + + + + + RaceManager::RaceManager() + { + first = 0; + last = 0; + } + + void RaceManager::add(RaceInfo *ri) + { + if (!first) + first = ri; + + if (last) + last->next = ri; + + last = ri; + } + + + + void RaceManager::readracelist() + { + al_ffblk info; + + // find all the directory names - each directory indicates a different race, + // and has the race name as well + + int err; + err = al_findfirst("gamex/gamedata/races/*", &info, FA_DIREC ); + + while (!err) + { + char *racename; + racename = info.name; + + if (strcmp(racename, ".") != 0 && strcmp(racename, "..") != 0) + { + + char fname[512]; + strcpy(fname, "gamex/gamedata/races/"); + strcat(fname, racename); + strcat(fname, "/race.ini"); + set_config_file(fname); + + + int r, g, b; + r = get_config_int("color", "r", 254); + g = get_config_int("color", "g", 1); + b = get_config_int("color", "b", 254); + + RaceInfo *ri; + ri = new RaceInfo(racename, makecol(r,g,b)); + add(ri); + + strncpy(ri->shipid, get_config_string("ship", "id", "none"), 16); + + ri->cinfo.doubling_period = get_config_float("colony", "doublingperiod", 10.0); + ri->cinfo.start_population_multiplier = get_config_float("colony", "startpopmultiplier", 1.0); + strcpy(ri->cinfo.env_type, get_config_string("colony", "envtype", "gaia")); + if (strlen(ri->cinfo.env_type) > 64) { tw_error("invalid env type"); } + + + strcpy(fname, "gamex/gamedata/races/"); + strcat(fname, racename); + strcat(fname, "/colonies.ini"); + ri->init_colonies(fname); + + strcpy(fname, "gamex/gamedata/races/"); + strcat(fname, racename); + strcat(fname, "/fleet.bmp"); + + BITMAP *bmp; + bmp = load_bitmap(fname, 0); + + SpaceSprite *fleetspr; + fleetspr = new SpaceSprite(bmp); + + ri->fleetsprite = fleetspr; + + destroy_bitmap(bmp); + + } + + + + err = al_findnext(&info); + } + + } + + + void RaceManager::writeracelist() + { + + RaceInfo *current; + current = first; + + while (current) + { + char fname[512]; + strcpy(fname, "gamex/gamedata/races/"); + strcat(fname, current->id); + strcat(fname, "/race.ini"); + set_config_file(fname); + + int r, g, b; + r = getr(current->color); + g = getg(current->color); + b = getb(current->color); + + set_config_int("color", "r", r); + set_config_int("color", "g", g); + set_config_int("color", "b", b); + + set_config_float("colony", "doublingperiod", current->cinfo.doubling_period); + set_config_float("colony", "startpopmultiplier", current->cinfo.start_population_multiplier); + set_config_string("colony", "envtype", current->cinfo.env_type); + + + current = current->next; + } + + } + + + + void RaceManager::animate_starmap(Frame *f) + { + RaceInfo *current; + current = first; + + while (current) + { + current->animate_starmap(f); + current = current->next; + } + } + Index: gamedata.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamedata.h 19 Dec 2003 23:33:35 -0000 1.4 --- gamedata.h 22 Dec 2003 09:37:08 -0000 1.5 *************** *** 7,22 **** ! class RaceInfo { ! void AI(); - int Ncolonies; - int Nmines; ! Vector2 spherecenter; ! double spheresize; }; class LocalPlayerInfo; --- 7,142 ---- ! ! ! ! class RaceInfo; ! ! // race-specific info ! class ColonyRaceInfo { ! public: ! char env_type[64]; ! double doubling_period; // double population in "years" ! double start_population_multiplier; ! }; ! // planet-specific info ! class ColonyPlanetInfo ! { ! public: ! char env_type[64]; }; + // patrol stuff + class Patrol + { + public: + Patrol(); + + double range; + int numhyperfleets; + int numsystemfleets; + int numcapitalfleets; + }; + + + class FGPresence : public Presence + { + public: + virtual void animate_starmap(Frame *f) {}; + }; + + + class RaceSettlement : public FGPresence + { + protected: + RaceInfo *race; + + public: + RaceSettlement *next; + int istar, iplanet, imoon; + + Patrol patrol; + + RaceSettlement(RaceInfo *arace); + virtual ~RaceSettlement(); + + void locate(int astar, int aplanet, int amoon); + + virtual void calculate(); + virtual void animate_starmap(Frame *f); + }; + + + class RaceColony : public RaceSettlement + { + protected: + + public: + RaceColony(RaceInfo *arace); + double population; + + virtual void calculate(); + }; + + + + class RaceInfo : public Presence + { + public: + RaceInfo *next; + + RaceInfo(char *arace_id, int acolor); + ~RaceInfo(); + + // Racemine *mines; + //int Ncolonies; + //int Nmines; + + //Vector2 spherecenter; + //double spheresize; + + char *id; + int color; + + SpaceSprite *fleetsprite; // is used in hyperspace, and in solar/planet view + // this class should clean it up... + + virtual void calculate(); + virtual void animate_starmap(Frame *f); + + ColonyRaceInfo cinfo; + + RaceColony *firstcol, *lastcol; + void init_colonies(char *ininame); + void add(RaceColony *rc); + + char shipid[16]; + }; + + + + + + class RaceManager + { + public: + RaceInfo *first, *last; + + RaceManager(); + + void add(RaceInfo *ri); + + void readracelist(); + void writeracelist(); + + virtual void animate_starmap(Frame *f); + }; + + extern RaceManager racelist; + + class LocalPlayerInfo; *************** *** 72,75 **** --- 192,196 ---- char name[64]; SpaceObject *o; + double scalepos; int Nsub; Index: gamegeneral.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamegeneral.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gamegeneral.cpp 19 Dec 2003 08:52:54 -0000 1.6 --- gamegeneral.cpp 22 Dec 2003 09:37:08 -0000 1.7 *************** *** 461,465 **** - XFleet::XFleet() { --- 461,464 ---- Index: gamehyper.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamehyper.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamehyper.cpp 15 Dec 2003 20:51:12 -0000 1.3 --- gamehyper.cpp 22 Dec 2003 09:37:08 -0000 1.4 *************** *** 19,22 **** --- 19,145 ---- #include "gamehyper.h" #include "gamesolarview.h" + #include "gamemelee.h" + + static const int ID_FLEET_HYPER = 0x09837491; + + + inline double sqr(double x) + { + return x*x; + } + + + class HyperFleet : public SpaceObject + { + public: + SpaceObject *follow; + double speed; + + HyperFleet(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite); + virtual void calculate(); + virtual void animate(Frame *f); + + RaceInfo *ri; + }; + + + HyperFleet::HyperFleet(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite) + : + SpaceObject(creator, opos, oangle, osprite) + { + follow = 0; + speed = 0; + + id = ID_FLEET_HYPER; + + layer = LAYER_SHIPS; + collide_flag_anyone = ALL_LAYERS; + collide_flag_sameteam = ALL_LAYERS; + collide_flag_sameship = ALL_LAYERS; + } + + + void HyperFleet::calculate() + { + if (!follow) + { + state = 0; + return; + } + + angle = trajectory_angle(follow); + vel = speed * unit_vector(angle); + + double R; + R = distance(follow); + if (R > 1000) + state = 0; + } + + void HyperFleet::animate(Frame *f) + { + Vector2 s = sprite->size(sprite_index); + Vector2 p = corner(pos, s ); + sprite->draw_character(p.x, p.y, sprite_index, makecol(0,0,0), f); + + } + + + void GameHyperspace::calc_enemies() + { + // check if you're in range of one of the colonies: + RaceInfo *a; + a = racelist.first; + + while (a) + { + RaceSettlement *b; + b = a->firstcol; + + while (b) + { + Vector2 P; + P = mapeverything.region[0]->sub[b->istar]->position; + + + double r; + r -= (P - player->pos / scalepos).length(); + + + if (r < b->patrol.range) + { + double density, chance, enemyspeed; + + enemyspeed = 0.1; + + density = 0.01; + density = 1; + + chance = (player->vel.length() + enemyspeed) * frame_time / scalepos; + chance *= density; + + + if (random(1.0) < chance) + { + // create a "enemy" object ... but how ? + HyperFleet *fl; + fl = new HyperFleet(0, player->pos+Vector2(100,100), 0, a->fleetsprite); + add(fl); + fl->speed = enemyspeed; + fl->follow = player; + fl->ri = a; + + } + } + + + + + b = b->next; + } + + a = a->next; + } + } *************** *** 250,253 **** --- 373,381 ---- pos = starmap->sub[playinf->istar]->position; } + + layer = LAYER_SHIPS; + collide_flag_anyone = ALL_LAYERS; + collide_flag_sameship = ALL_LAYERS; + collide_flag_sameteam = ALL_LAYERS; } *************** *** 607,614 **** --- 735,745 ---- hyperexpl->expand(); + message.print(1500, 14, "speed = %f", player->vel.length() * 1E3); + t = get_time2() - t;// - paused_time; tic_history->add_element(pow(t, HIST_POWER)); + calc_enemies(); } *************** *** 632,635 **** --- 763,796 ---- // a game, and by setting a request pointer to that allocated game :) gamerequest = new GameSolarview(); + } + + // if you're close to a hyperfleet + if (player->collisionwith) + { + SpaceObject *o; + o = player->collisionwith; + if ( o->id == ID_FLEET_HYPER) + { + // then enter melee ... + player->vel = 0; + + // what's the race ? + XFleet *f; + f = new XFleet(); + + f->add(((HyperFleet*)o)->ri->shipid, 3); + + // spawn a subgame + if (!gamerequest && !next) + { + GameMelee *g; + g = new GameMelee(); + g->set_xfleet(f); + + gamerequest = g; + } + + o->state = 0; + } } } Index: gamehyper.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamehyper.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamehyper.h 15 Dec 2003 20:51:12 -0000 1.3 --- gamehyper.h 22 Dec 2003 09:37:08 -0000 1.4 *************** *** 87,90 **** --- 87,92 ---- virtual void init_menu(); + + void calc_enemies(); }; Index: gamemelee.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamemelee.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamemelee.cpp 15 Dec 2003 20:51:12 -0000 1.4 --- gamemelee.cpp 22 Dec 2003 09:37:08 -0000 1.5 *************** *** 35,39 **** - class InitShipGeneral { --- 35,38 ---- *************** *** 98,101 **** --- 97,136 ---- } + #include "../melee.h" + #include "../melee/mframe.h" + + Ship *GameMelee::create_ship(const char *id, Vector2 pos, double angle, int team) + { + Control *c = 0; + int channel = 0; + + c = getController("WussieBot", "whatever", channel); + if (!c) { + tw_error("Game::create_control - bad control type"); + } + // c->load(file, config); + add(c); + + + ShipType *type = shiptype(id); + if (!type) + {tw_error("Game::create_ship - bad ship id (%s)", id);} + /*if(!ini) { + sprintf(buffer, "ships/shp%s.ini", id); + ini = buffer; + } + log_file(buffer);*/ + // log_file(type->file); + set_config_file(type->file); + // if (team == 0) team = new_team(); + Ship *s = type->get_ship(pos, angle, get_code(new_ship(), team)); + if (c) + c->select_ship(s, id); + // add_target(s); + s->attributes |= ATTRIB_NOTIFY_ON_DEATH; + return s; + } + + *************** *** 156,160 **** for ( i = 0; i < enemyfleet->Nships; ++i ) { ! s = createship(enemyfleet->info->name, Vector2(0,0), 0, team_player); s->layer = LAYER_SHIPS; s->collide_flag_anyone = ALL_LAYERS; --- 191,196 ---- for ( i = 0; i < enemyfleet->Nships; ++i ) { ! //s = createship(enemyfleet->info->name, Vector2(0,0), 0, team_player); ! s = create_ship(enemyfleet->info->name, Vector2(0,0), 0, team_player); s->layer = LAYER_SHIPS; s->collide_flag_anyone = ALL_LAYERS; Index: gamemelee.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamemelee.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamemelee.h 14 Dec 2003 14:20:58 -0000 1.2 --- gamemelee.h 22 Dec 2003 09:37:08 -0000 1.3 *************** *** 34,37 **** --- 34,40 ---- virtual void handle_edge(SpaceLocation *s); + + + virtual Ship *create_ship(const char *id, Vector2 pos, double angle, int team); }; Index: gameplanetview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetview.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gameplanetview.cpp 19 Dec 2003 23:33:35 -0000 1.7 --- gameplanetview.cpp 22 Dec 2003 09:37:08 -0000 1.8 *************** *** 416,421 **** - - GamePlanetview::~GamePlanetview() { --- 416,419 ---- Index: gamestarmap.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gamestarmap.cpp 19 Dec 2003 08:52:54 -0000 1.5 --- gamestarmap.cpp 22 Dec 2003 09:37:08 -0000 1.6 *************** *** 18,22 **** ! --- 18,22 ---- ! //#include "gamedata.h" *************** *** 50,54 **** wininfo.zoomlimit(size.x); wininfo.center(Vector2(0,0)); ! //wininfo.scaletowidth(size.x); // zoom out to this width. --- 50,54 ---- wininfo.zoomlimit(size.x); wininfo.center(Vector2(0,0)); ! wininfo.scaletowidth(0.5 * size.x); // zoom out to this width. *************** *** 64,67 **** --- 64,68 ---- // create star objects ?! starmap = mapeverything.region[0]; // use the starmap of the 1st region + starmap->scalepos = scalepos; for ( i = 0; i < starmap->Nsub; ++i ) *************** *** 119,122 **** --- 120,140 ---- mapeditor->set_interface( Tedit, breplace, bnew ); mapeditor->set_mapinfo( starmap, 1, scalepos); + + + + + /* + // create a colony somewhere ?? For testing purpose only ... + RaceInfo *race; + RaceColony *colony; + + race = new RaceInfo("testrace", makecol(100,20,20)); + add(race); + + colony = new RaceColony(race); + colony->locate(0, 0, -1); + colony->patrol.range = 1000; + add(colony); + */ } *************** *** 180,183 **** --- 198,204 ---- + // draw race territories + racelist.animate_starmap(frame); + // draw a grid ... int ix, iy; *************** *** 207,210 **** --- 228,232 ---- GameBare::animate(frame); + } Index: projectx.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/projectx.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** projectx.cpp 19 Dec 2003 23:33:35 -0000 1.7 --- projectx.cpp 22 Dec 2003 09:37:08 -0000 1.8 *************** *** 47,52 **** - - void ProjectX::init() { --- 47,50 ---- *************** *** 55,58 **** --- 53,59 ---- playerinfo.init("gamex/player/playerinfo.ini"); + // initialize races info + racelist.readracelist(); + // initialize the starmap ... *************** *** 79,83 **** // add( new GameSolarview() ); // add( new GamePlanetview() ); ! add( new GamePlanetscan() ); // add( new GameMelee() ); // add( new GameDialogue() ); // the editor --- 80,84 ---- // add( new GameSolarview() ); // add( new GamePlanetview() ); ! // add( new GamePlanetscan() ); // add( new GameMelee() ); // add( new GameDialogue() ); // the editor |
From: <geo...@us...> - 2003-12-22 09:37:12
|
Update of /cvsroot/timewarp/source/gamex/stuff In directory sc8-pr-cvs1:/tmp/cvs-serv3063/gamex/stuff Modified Files: space_body.cpp Log Message: adding race information Index: space_body.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/stuff/space_body.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** space_body.cpp 19 Dec 2003 08:52:54 -0000 1.2 --- space_body.cpp 22 Dec 2003 09:37:08 -0000 1.3 *************** *** 472,475 **** --- 472,476 ---- id = MAPOBJ_ID; layer = LAYER_SHOTS; + sprite_index = 0; } *************** *** 482,486 **** if (scale < 0.25) scale = 0.25; ! sprite->draw(corner(pos, s ), s * scale, sprite_index, f); } --- 483,487 ---- if (scale < 0.25) scale = 0.25; ! sprite->draw(corner(pos)-0.5*s*scale, s * scale, sprite_index, f); } |
From: <geo...@us...> - 2003-12-22 09:35:48
|
Update of /cvsroot/timewarp/gamex/gamedata/races/earthling In directory sc8-pr-cvs1:/tmp/cvs-serv2814/races/earthling Added Files: colonies.ini fleet.bmp race.ini Log Message: adding race information --- NEW FILE: colonies.ini --- N = 3 [colony000] name = testcol1 star = 0 planet = 0 moon = -1 population = 10 [colony001] name = testcol2 star = 10 planet = 0 moon = -1 population = 10000 [colony002] name = testcol2 star = 20 planet = 0 moon = -1 population = 1000000 --- NEW FILE: fleet.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: race.ini --- [ship] id = earcr [color] r = 100 g = 100 b = 100 [colony] doublingperiod = 10.0 startpopmultiplier = 1.0 envtype = gaia |
From: <geo...@us...> - 2003-12-22 09:35:04
|
Update of /cvsroot/timewarp/gamex/gamedata/races/earthling In directory sc8-pr-cvs1:/tmp/cvs-serv2656/earthling Log Message: Directory /cvsroot/timewarp/gamex/gamedata/races/earthling added to the repository |
From: <geo...@us...> - 2003-12-22 09:34:50
|
Update of /cvsroot/timewarp/gamex/gamedata/races In directory sc8-pr-cvs1:/tmp/cvs-serv2617/races Log Message: Directory /cvsroot/timewarp/gamex/gamedata/races added to the repository |
From: <geo...@us...> - 2003-12-22 09:34:35
|
Update of /cvsroot/timewarp/gamex/gamedata In directory sc8-pr-cvs1:/tmp/cvs-serv2587/gamedata Log Message: Directory /cvsroot/timewarp/gamex/gamedata added to the repository |
Update of /cvsroot/timewarp/gamex/interface/planetscan In directory sc8-pr-cvs1:/tmp/cvs-serv3476 Added Files: backgr.bmp exit_default.bmp info.txt map_backgr.bmp starname_backgr.bmp surface_backgr.bmp zoomin_default.bmp zoomout_default.bmp Log Message: improvement to the planet-scan gametype --- NEW FILE: backgr.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: exit_default.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: info.txt --- gamex/interface/planetscan/surface_backgr_y = 389 gamex/interface/planetscan/surface_backgr_x = 197 gamex/interface/planetscan/map_backgr_y = 32 gamex/interface/planetscan/map_backgr_x = 15 gamex/interface/planetview/starname_backgr_y = 4 gamex/interface/planetview/starname_backgr_x = 233 gamex/interface/planetview/map_backgr_y = 33 gamex/interface/planetview/map_backgr_x = 15 res = 800 --- NEW FILE: map_backgr.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: starname_backgr.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: surface_backgr.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: zoomin_default.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: zoomout_default.bmp --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/timewarp/gamex/planetscan In directory sc8-pr-cvs1:/tmp/cvs-serv3270 Modified Files: planet_small_purp_01.bmp Added Files: moon_small_brown_01.bmp moon_small_purp_01.bmp planet_big_blue_01.bmp planet_small_red_01.bmp Removed Files: map_small_purp_01.bmp Log Message: improvement to the planet-scan gametype --- NEW FILE: moon_small_brown_01.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: moon_small_purp_01.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: planet_big_blue_01.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: planet_small_red_01.bmp --- (This appears to be a binary file; contents omitted.) Index: planet_small_purp_01.bmp =================================================================== RCS file: /cvsroot/timewarp/gamex/planetscan/planet_small_purp_01.bmp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvs0XIc6n and /tmp/cvsKGGQ0A differ --- map_small_purp_01.bmp DELETED --- |
From: <geo...@us...> - 2003-12-19 23:34:11
|
Update of /cvsroot/timewarp/gamex/interface/planetscan In directory sc8-pr-cvs1:/tmp/cvs-serv2824/planetscan Log Message: Directory /cvsroot/timewarp/gamex/interface/planetscan added to the repository |
Update of /cvsroot/timewarp/source/gamex In directory sc8-pr-cvs1:/tmp/cvs-serv2680/gamex Modified Files: gamedata.cpp gamedata.h gameplanetscan.cpp gameplanetscan.h gameplanetview.cpp gameproject.cpp gameproject.h gamesolarview.cpp projectx.cpp Log Message: improvement to the planet-scan gametype Index: gamedata.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamedata.cpp 14 Dec 2003 22:19:55 -0000 1.3 --- gamedata.cpp 19 Dec 2003 23:33:35 -0000 1.4 *************** *** 29,33 **** istar = get_config_int(0, "Star", -1); iplanet = get_config_int(0, "Planet", -1); ! iplanetcode = get_config_int(0, "PlanetCode", -1); // of planets and moons } --- 29,33 ---- istar = get_config_int(0, "Star", -1); iplanet = get_config_int(0, "Planet", -1); ! imoon = get_config_int(0, "Moon", -1); // of planets and moons } *************** *** 42,46 **** set_config_int(0, "Star", istar); set_config_int(0, "Planet", iplanet); ! set_config_int(0, "PlanetCode", iplanetcode); } --- 42,47 ---- set_config_int(0, "Star", istar); set_config_int(0, "Planet", iplanet); ! set_config_int(0, "Moon", imoon); ! //set_config_int(0, "PlanetCode", iplanetcode); } Index: gamedata.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamedata.h 19 Dec 2003 08:52:54 -0000 1.3 --- gamedata.h 19 Dec 2003 23:33:35 -0000 1.4 *************** *** 36,43 **** // <0 means you're in planetsys view ! int iplanetcode; - // >= 0 mean you're in explore view. - // each planet should have a unique code. void init(char *filename); --- 36,41 ---- // <0 means you're in planetsys view ! int imoon; void init(char *filename); Index: gameplanetscan.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetscan.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gameplanetscan.cpp 18 Nov 2003 17:18:49 -0000 1.1.1.1 --- gameplanetscan.cpp 19 Dec 2003 23:33:35 -0000 1.2 *************** *** 25,28 **** --- 25,41 ---- + void GamePlanetscan::init_menu() + { + // place the menu into video-memory, cause we're using this as basis for + // drawing; the game draws onto part of the menu. + T = new TWindow("gamex/interface/planetscan", 0, 0, game_screen, true); + + maparea = new Area(T, "map_"); + + surf_area = new Area(T, "surface_"); + } + + + void GamePlanetscan::init() { *************** *** 31,39 **** double H = 1000; ! size = Vector2(H, H); prepare(); - // mapwrap = false; - wininfo.init( Vector2(500,500), 800.0, view->frame ); wininfo.zoomlimit(size.x); wininfo.scaletowidth(size.x); // zoom out to this width. --- 44,50 ---- double H = 1000; ! size = Vector2(H, H*tempframe->ratio); prepare(); wininfo.zoomlimit(size.x); wininfo.scaletowidth(size.x); // zoom out to this width. *************** *** 41,80 **** // create star objects ?! ! int istar, iplanet; ! MapSpacebody *starmap, *solarmap, *planetmap; starmap = mapeverything.region[0]; // use the starmap of the 1st region ! istar = 0; ! solarmap = starmap->sub[istar]; // use the solarsystem belonging to that star ! iplanet = 0; planetmap = solarmap->sub[iplanet]; // use the planet (and moons) belonging to that planet orbit. - SpaceObject *solarbody; //SpaceSprite *spr; - // load the planet (or moon) sprite char *typestr; char txt[512]; - typestr = startypelist->type[planetmap->type].type_string; - sprintf(txt, "gamex/planetscan/planet_%s_01.bmp", typestr); - planetspr = create_sprite( txt, SpaceSprite::MASKED ); - solarbody = new SolarBody(0, 0.5*size, 0.0, planetspr, 0.5*size, iplanet, - 0,0,0,0); - planetmap->o = solarbody; - add(solarbody); - solarbody->pos = Vector2(500, 400); ! // load the surface map of this planet (or moon) ! sprintf(txt, "gamex/planetscan/map_%s_01.bmp",typestr); ! map_bmp = load_bitmap(txt, 0); ! // (at the moment, this is resolution dependent...) ! // this should be scaled using a scaled blit... - //solarbody = new SolarBody(0, planetmap->sub[i]->position, 0.0, spr); - //planetmap->sub[i]->o = solarbody; - //add(solarbody); // the player --- 52,117 ---- // create star objects ?! ! int istar, iplanet, imoon; ! MapSpacebody *starmap, *solarmap, *planetmap, *moonmap; starmap = mapeverything.region[0]; // use the starmap of the 1st region ! istar = playerinfo.istar; ! iplanet = playerinfo.iplanet; ! imoon = playerinfo.imoon; ! if (istar == -1) ! istar = 0; ! if (iplanet == -1) ! iplanet = 0; ! ! solarmap = starmap->sub[istar]; // use the solarsystem belonging to that star planetmap = solarmap->sub[iplanet]; // use the planet (and moons) belonging to that planet orbit. + if (imoon >= 0) + moonmap = planetmap->sub[imoon]; // use the planet (and moons) belonging to that planet orbit. + else + moonmap = 0; + //SpaceSprite *spr; char *typestr; char txt[512]; ! if ( imoon == -1 ) ! { ! // exploring a PLANET ! // load the planet sprite + typestr = planettypelist->type[planetmap->type].type_string; + + // load the surface map of this planet (or moon) + sprintf(txt, "gamex/planetscan/planet_%s_01.bmp",typestr); + map_bmp = load_bitmap(txt, 0); + // (at the moment, this is resolution dependent...) + // this should be scaled using a scaled blit... + + } else { + + // exploring a MOON + typestr = moontypelist->type[moonmap->type].type_string; + + // load the surface map of this planet (or moon) + sprintf(txt, "gamex/planetscan/moon_%s_01.bmp",typestr); + map_bmp = load_bitmap(txt, 0); + // (at the moment, this is resolution dependent...) + // this should be scaled using a scaled blit... + + } + + // map_bmp should have 32 bit depth, because colors are assumed to come from + // a 32 bpp depth image. Loading from disk is sometimes (or often) 24 bit. + BITMAP *tmp; + tmp = create_bitmap_ex(32, map_bmp->w, map_bmp->h); + clear_to_color(tmp, makecol32(255,0,255)); + blit(map_bmp, tmp, 0, 0, 0, 0, tmp->w, tmp->h); + destroy_bitmap(map_bmp); + map_bmp = tmp; // the player *************** *** 84,87 **** --- 121,169 ---- add(player); player->pos = Vector2(500,500); + + + + + // add a 3d rotating planet ?! + SpaceSprite *dummy; + + int planet_radius = 100; + int image_size = 2 * planet_radius; + + BITMAP *image32bit = create_bitmap_ex(32, image_size, image_size); + clear_to_color(image32bit, makecol32(255,0,255)); + circlefill( image32bit, + image32bit->w/2, image32bit->h/2, + image32bit->w/2 - 2, makecol(255,255,255)); + + dummy = new SpaceSprite(image32bit, SpaceSprite::IRREGULAR | SpaceSprite::MASKED | SpaceSprite::NO_AA); + + Vector2 opos = 0.5 * map_size; + SpaceSprite *color_map, *spec_map; + + color_map = new SpaceSprite(map_bmp, SpaceSprite::IRREGULAR | SpaceSprite::MASKED ); + + spec_map = 0; + int aPlanetUsespec = 0; + + double tilt, spin, sun_hangle, sun_vangle; + tilt = tw_random(-40.0, 40.0); + spin = tw_random(-30.0, 30.0); + sun_vangle = tw_random(-20.0, 60.0); + sun_hangle = tw_random(-45.0, 45.0); + double sunr = 1.0; + double sung = 1.0; + double sunb = 1.0; + + rotatingplanet = new Planet3D(opos, color_map, spec_map, dummy, + planet_radius, aPlanetUsespec, + spin, tilt, + sun_vangle, sun_hangle, + sunr, sung, sunb, + true); + + // you should delete dummy yourself ? + + } *************** *** 90,94 **** { - delete planetspr; delete playerspr; destroy_bitmap(map_bmp); --- 172,175 ---- *************** *** 119,122 **** --- 200,206 ---- wininfo.center(0.5*size); + + rotatingplanet->calculate(); + } *************** *** 125,135 **** // draw the planet background. ! int ix, iy; ! ix = 100; ! iy = 300; ! blit(map_bmp, frame->surface, 0, 0, ix, iy, map_bmp->w, map_bmp->h); GameBare::animate(frame); } --- 209,223 ---- // draw the planet background. ! blit(map_bmp, surf_area->backgr, 0, 0, 0, 0, map_bmp->w, map_bmp->h); + int x, y; + + x = (maparea->backgr->w - rotatingplanet->size.x) / 2; + y = (maparea->backgr->h - rotatingplanet->size.y) / 2; + rotatingplanet->animate_pre(); + rotatingplanet->get_sprite()->draw(x, y, 0, maparea->backgr); GameBare::animate(frame); + } Index: gameplanetscan.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetscan.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gameplanetscan.h 18 Nov 2003 17:18:49 -0000 1.1.1.1 --- gameplanetscan.h 19 Dec 2003 23:33:35 -0000 1.2 *************** *** 8,17 **** class GamePlanetscan : public GameBare { - WindowInfo wininfo; class ThePlaya : public LocalPlayerInfo --- 8,21 ---- + #include "../other/planet3d.h" class GamePlanetscan : public GameBare { + Area *surf_area; + // SpaceObject *solarbody; + + Planet3D *rotatingplanet; class ThePlaya : public LocalPlayerInfo *************** *** 24,27 **** --- 28,32 ---- virtual void init(); + virtual void init_menu(); virtual void quit(); //virtual bool handle_key(int k); *************** *** 31,35 **** BITMAP *map_bmp; ! SpaceSprite *playerspr, *planetspr; }; --- 36,41 ---- BITMAP *map_bmp; ! SpaceSprite *playerspr; //*planetspr; ! }; Index: gameplanetview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetview.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gameplanetview.cpp 19 Dec 2003 08:52:54 -0000 1.6 --- gameplanetview.cpp 19 Dec 2003 23:33:35 -0000 1.7 *************** *** 30,33 **** --- 30,36 ---- + static const int ID_MAP_PLANET = 0x0b8f934ae; + + *************** *** 123,127 **** planetmap->o = solarbody; add(solarbody); ! solarbody->id = 0; // so that it's not editable by the mapeditor // load moon sprites --- 126,131 ---- planetmap->o = solarbody; add(solarbody); ! ! solarbody->id = ID_MAP_PLANET; // so that it's not editable by the mapeditor // load moon sprites *************** *** 339,342 **** --- 343,363 ---- } + } else if (player->collisionwith->id == MAPOBJ_ID || + player->collisionwith->id == ID_MAP_PLANET) + { + player->vel = 0; + + if (player->collisionwith->id == MAPOBJ_ID) + playerinfo.imoon = ((SolarBody*) player->collisionwith)->starnum; + else + playerinfo.imoon = -1; // it's not a moon, but the planet then. + + if (!gamerequest && !next) + { + GamePlanetscan *g; + g = new GamePlanetscan(); + + gamerequest = g; + } } } Index: gameproject.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gameproject.cpp 19 Dec 2003 08:52:54 -0000 1.6 --- gameproject.cpp 19 Dec 2003 23:33:35 -0000 1.7 *************** *** 703,707 **** - Frame2::Frame2(int max_items) : --- 703,706 ---- Index: gameproject.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gameproject.h 19 Dec 2003 08:52:54 -0000 1.6 --- gameproject.h 19 Dec 2003 23:33:35 -0000 1.7 *************** *** 130,134 **** Histograph *tic_history; Histograph *render_history; ! void GameBare::show_ticinfo(Frame *f, Histograph *tic_history, Histograph *render_history, double hist_power); }; --- 130,134 ---- Histograph *tic_history; Histograph *render_history; ! void show_ticinfo(Frame *f, Histograph *tic_history, Histograph *render_history, double hist_power); }; Index: gamesolarview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamesolarview.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamesolarview.cpp 19 Dec 2003 08:52:54 -0000 1.4 --- gamesolarview.cpp 19 Dec 2003 23:33:35 -0000 1.5 *************** *** 227,231 **** k = solarmap->sub[i]->type; ! solarbody = new SolarBody(0, solarmap->sub[i]->position, 0.0, planetspr[k], sunpos, k, sunpos+Poffs, R, b, col // ellips information ); --- 227,231 ---- k = solarmap->sub[i]->type; ! solarbody = new SolarBody(0, solarmap->sub[i]->position, 0.0, planetspr[k], sunpos, i, sunpos+Poffs, R, b, col // ellips information ); Index: projectx.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/projectx.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** projectx.cpp 19 Dec 2003 08:52:54 -0000 1.6 --- projectx.cpp 19 Dec 2003 23:33:35 -0000 1.7 *************** *** 78,83 **** // add( new GameStarmap() ); // add( new GameSolarview() ); ! add( new GamePlanetview() ); ! // add( new GamePlanetscan() ); // add( new GameMelee() ); // add( new GameDialogue() ); // the editor --- 78,83 ---- // add( new GameStarmap() ); // add( new GameSolarview() ); ! // add( new GamePlanetview() ); ! add( new GamePlanetscan() ); // add( new GameMelee() ); // add( new GameDialogue() ); // the editor |
From: <geo...@us...> - 2003-12-19 23:33:38
|
Update of /cvsroot/timewarp/source/other In directory sc8-pr-cvs1:/tmp/cvs-serv2680/other Modified Files: planet3d.cpp Added Files: planet3d.h Log Message: improvement to the planet-scan gametype --- NEW FILE: planet3d.h --- #ifndef _PLANET_3D_ #define _PLANET_3D_ #include "../melee/mcbodies.h" class Planet3D : public Planet { BITMAP *image32bit; SpaceSprite *map; // color map SpaceSprite *dummy; // the "target" sprite where the 2d planet image is stored int image_size, visual_size; int PlanetUsespec; double theta, fi, rad; double spin;//degrees per second int draw_reserve; // bool AA; int mapW, mapH; // unsigned char color_map[1000][500][4]; // double spec_map[1000][500]; struct base_map_type {double lat, lon, diff, spec;} *base_map; unsigned int *base_map_linear; // mapping of coordinates unsigned int *base_shade_linear, *base_spec_linear; // shades ? unsigned char *color_map_linear, *spec_map_linear; unsigned int *base_map_and_shade_resorted; // linear means in this case, a linear array int jmin[1000], jmax[1000]; public: Planet3D(Vector2 opos, SpaceSprite *color_map, SpaceSprite *spec_map, SpaceSprite *ObjectSprite, int planet_radius, int aPlanetUsespec, double turn_rate, double tilt, double sun_vertangle, // positive is pointing down double sun_horizangle, // oriented along x double sunr, double sung, double sunb, bool invcolor = false); virtual void calculate(); void animate_pre(); // does lots of calculations, that are needed for drawing - it puts together the picture virtual void animate(Frame * space); ~Planet3D(); }; #endif Index: planet3d.cpp =================================================================== RCS file: /cvsroot/timewarp/source/other/planet3d.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** planet3d.cpp 26 Oct 2003 10:43:17 -0000 1.12 --- planet3d.cpp 19 Dec 2003 23:33:35 -0000 1.13 *************** *** 12,16 **** #include "../ship.h" REGISTER_FILE - #include "../melee/mcbodies.h" #include "../melee/mview.h" --- 12,15 ---- *************** *** 21,24 **** --- 20,25 ---- #include <string.h> + #include "planet3d.h" + SpaceSprite::SpaceSprite(BITMAP *image, int _attributes) *************** *** 60,112 **** - class Planet3D : public Planet { - - BITMAP *image32bit; - SpaceSprite *map; // color map - SpaceSprite *dummy; // the "target" sprite where the 2d planet image is stored - - int image_size, visual_size; - - int PlanetUsespec; - - double theta, fi, rad; - double spin;//degrees per second - - int draw_reserve; - - // bool AA; - - int mapW, mapH; - - // unsigned char color_map[1000][500][4]; - // double spec_map[1000][500]; - - struct base_map_type {double lat, lon, diff, spec;} *base_map; - - unsigned int *base_map_linear; // mapping of coordinates - unsigned int *base_shade_linear, *base_spec_linear; // shades ? - unsigned char *color_map_linear, *spec_map_linear; - - unsigned int *base_map_and_shade_resorted; - // linear means in this case, a linear array - - int jmin[1000], jmax[1000]; - - public: - - Planet3D(Vector2 opos, SpaceSprite *color_map, SpaceSprite *spec_map, - SpaceSprite *ObjectSprite, - int planet_radius, int aPlanetUsespec, - double turn_rate, double tilt, - double sun_vertangle, // positive is pointing down - double sun_horizangle, // oriented along x - double sunr, double sung, double sunb); - - virtual void calculate(); - virtual void animate(Frame * space); - - ~Planet3D(); - }; - /* --- 61,64 ---- *************** *** 309,313 **** double sun_vertangle, // positive is pointing down double sun_horizangle, // oriented along x ! double sun_r, double sun_g, double sun_b) : Planet( opos, ObjectSprite, 0 ) --- 261,266 ---- double sun_vertangle, // positive is pointing down double sun_horizangle, // oriented along x ! double sun_r, double sun_g, double sun_b, ! bool invcolor) : Planet( opos, ObjectSprite, 0 ) *************** *** 349,362 **** ccc=getpixel(map->get_bitmap(0), i, j); ! int spec = getpixel(spec_map->get_bitmap(0), i, j); unsigned char r, g, b; unsigned char sr, sg, sb; // map coordinate int k = (2*mapW*mapH) - (j+1)*(2*mapW) + i; ! r = getr32(ccc); ! g = getg32(ccc); ! b = getb32(ccc); // filter the colors by the reference sun --- 302,329 ---- ccc=getpixel(map->get_bitmap(0), i, j); ! int spec; ! if (spec_map) ! spec = getpixel(spec_map->get_bitmap(0), i, j); ! else ! spec = makecol(200,200,200); unsigned char r, g, b; unsigned char sr, sg, sb; + // AT THIS MOMENT, it's a good moment to find out in which way the + // videocard interprets the colors ... as rgb, or as bgr ??!! + // map coordinate int k = (2*mapW*mapH) - (j+1)*(2*mapW) + i; ! if (!invcolor) ! { ! r = getr32(ccc); ! g = getg32(ccc); ! b = getb32(ccc); ! } else { ! b = getr32(ccc); ! g = getg32(ccc); ! r = getb32(ccc); ! } // filter the colors by the reference sun *************** *** 394,398 **** delete map; ! delete spec_map; map = 0; spec_map = 0; --- 361,366 ---- delete map; ! if (spec_map) ! delete spec_map; map = 0; spec_map = 0; *************** *** 733,739 **** } ! void Planet3D::animate( Frame* space ) { ! STACKTRACE --- 701,707 ---- } ! void Planet3D::animate_pre() { ! STACKTRACE; *************** *** 1151,1155 **** --- 1119,1130 ---- // blit can convert color depths (I think?) blit(image32bit, tmp, 0, 0, 0, 0, image_size, image_size); + } + + void Planet3D::animate( Frame* space ) + { + STACKTRACE; + + animate_pre(); dummy->animate(pos, 0, space); |
From: <geo...@us...> - 2003-12-19 23:33:38
|
Update of /cvsroot/timewarp/source/melee In directory sc8-pr-cvs1:/tmp/cvs-serv2680/melee Modified Files: mframe.cpp mframe.h mgame.h Log Message: improvement to the planet-scan gametype Index: mframe.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mframe.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mframe.cpp 12 Dec 2003 00:15:43 -0000 1.18 --- mframe.cpp 19 Dec 2003 23:33:35 -0000 1.19 *************** *** 1373,1374 **** --- 1373,1383 ---- return; } + + + void Physics::log_file (const char *fname) + { + set_config_file(fname); + }; + + + Index: mframe.h =================================================================== RCS file: /cvsroot/timewarp/source/melee/mframe.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mframe.h 26 Oct 2003 10:43:17 -0000 1.10 --- mframe.h 19 Dec 2003 23:33:35 -0000 1.11 *************** *** 128,132 **** // moved ROB - from mgame to here. bool friendly_fire; ! double shot_relativity;}; --- 128,136 ---- // moved ROB - from mgame to here. bool friendly_fire; ! double shot_relativity; ! ! // to init parameters of space-objects... ! virtual void log_file (const char *fname); ! }; *************** *** 170,173 **** --- 174,178 ---- //inline int get_serial() const {return _serial;} + }; Index: mgame.h =================================================================== RCS file: /cvsroot/timewarp/source/melee/mgame.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mgame.h 12 Nov 2003 03:21:10 -0000 1.10 --- mgame.h 19 Dec 2003 23:33:35 -0000 1.11 *************** *** 70,74 **** void log_int (int channel, unsigned int &data) {log_int (channel,*(int*)&data);} void log_data (int channel, void *data, int length); //helper for using the logging system ! void log_file (const char *fname); void log_fleet(int channel, class Fleet *fleet); int is_local ( int channel ) ; --- 70,74 ---- void log_int (int channel, unsigned int &data) {log_int (channel,*(int*)&data);} void log_data (int channel, void *data, int length); //helper for using the logging system ! virtual void log_file (const char *fname); void log_fleet(int channel, class Fleet *fleet); int is_local ( int channel ) ; |
From: <geo...@us...> - 2003-12-19 08:52:58
|
Update of /cvsroot/timewarp/source/gamex In directory sc8-pr-cvs1:/tmp/cvs-serv29070/gamex Modified Files: gamedata.h gamegeneral.cpp gameplanetview.cpp gameplanetview.h gameproject.cpp gameproject.h gamesolarview.cpp gamesolarview.h gamestarmap.cpp gamestarmap.h projectx.cpp Log Message: map editing Index: gamedata.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamedata.h 14 Dec 2003 22:19:55 -0000 1.2 --- gamedata.h 19 Dec 2003 08:52:54 -0000 1.3 *************** *** 4,8 **** #include "../melee/mframe.h" ! --- 4,8 ---- #include "../melee/mframe.h" ! #include <stdio.h> Index: gamegeneral.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamegeneral.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gamegeneral.cpp 15 Dec 2003 20:51:12 -0000 1.5 --- gamegeneral.cpp 19 Dec 2003 08:52:54 -0000 1.6 *************** *** 219,226 **** --- 219,229 ---- pos += space_center; + /* while (pos.x < -map_size.x/2) pos.x += map_size.x; while (pos.x > map_size.x/2) pos.x -= map_size.x; while (pos.y < -map_size.y/2) pos.y += map_size.x; while (pos.y > map_size.y/2) pos.y -= map_size.x; + */ + normalize(pos); return pos; Index: gameplanetview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetview.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gameplanetview.cpp 15 Dec 2003 20:51:12 -0000 1.5 --- gameplanetview.cpp 19 Dec 2003 08:52:54 -0000 1.6 *************** *** 89,125 **** - // from this, you know the planet position, relative to the sun - we use it - // the other way around this time: the sun position, relative to the planet !! - Vector2 sunpos; - double R, angle, b, b_sqrt; - - R = planetmap->position.y * 0.5*size.x; - angle = (PI/180) * planetmap->position.x; - - b = 1.0; - b_sqrt = sqrt(b); - - double c; - c = 10; - R *= c; - - // there is no extra offset; that's already in the planet pos ... you only need the - // distance to the center, not the center+offset, of the ellips. - - Vector2 P; - P = R*Vector2(cos(angle), (1/b_sqrt)*sin(angle)); ! sunpos = -P; // increase the distance .. as if you've zoomed in 10 times. ! // ok, this is the sun's position relative to the planet. ! Vector2 centerpos; ! centerpos = 0.5 * size; - //Vector2 offs; - //offs = Vector2(3E3, 2E3); - //sunpos = centerpos + offs; // temp value. SpaceObject *solarbody; --- 89,102 ---- ! // position of the planet relative to the sun ! Vector2 relplanetpos; ! relplanetpos = planetmap->position; Vector2 centerpos; ! centerpos = Vector2(0.5, 0.25) * size; SpaceObject *solarbody; *************** *** 129,141 **** char txt[512]; sprintf(txt, "gamex/planetview/planet_%s_01.bmp", - //startypelist->type[planetmap->type].type_string); planettypelist->type[planetmap->type].type_string); planetspr = create_sprite( txt, SpaceSprite::MASKED ); ! //double b = 1.0; ! //double R = (sunpos - centerpos).length(); ! solarbody = new SolarBody(0, centerpos, 0.0, planetspr, centerpos+sunpos, iplanet, ! centerpos+sunpos, R, b, makecol(115,0,0)); planetmap->o = solarbody; add(solarbody); // load moon sprites --- 106,127 ---- char txt[512]; sprintf(txt, "gamex/planetview/planet_%s_01.bmp", planettypelist->type[planetmap->type].type_string); planetspr = create_sprite( txt, SpaceSprite::MASKED ); ! ! Vector2 Poffs; ! int col; ! double R; ! ! double b = b_default; ! ellipsparams(relplanetpos, b, R, Poffs, col); ! ! Vector2 sunpos; ! sunpos = centerpos - relplanetpos; // "offset center" of the ellips. ! solarbody = new SolarBody(0, centerpos, 0.0, planetspr, sunpos, iplanet, ! sunpos+Poffs, R, b, makecol(115,0,0)); ! planetmap->o = solarbody; add(solarbody); + solarbody->id = 0; // so that it's not editable by the mapeditor // load moon sprites *************** *** 151,181 **** for ( i = 0; i < planetmap->Nsub; ++i ) { - // char txt[512]; - // sprintf(txt, "gamex/planetview/moon_%s_01.bmp", planetmap->sub[i]->type); - // spr = create_sprite( txt, SpaceSprite::MASKED ); - - - // ellips info ... similar to solar_view.cpp - double R, angle, b, b_sqrt; - - R = planetmap->sub[i]->position.y * 0.5*size.x; - angle = (PI/180) * planetmap->sub[i]->position.x; - - b = 2.0; - b_sqrt = sqrt(b); - Vector2 Poffs; - Poffs = Vector2(0, 0.25 * R/b_sqrt); - - Vector2 P; - P = centerpos + Poffs + R*Vector2(cos(angle), (1/b_sqrt)*sin(angle)); - - int col; ! col = makecol(115,0,0); int k; k = planetmap->sub[i]->type; ! solarbody = new SolarBody(0, P, 0.0, moonspr[k], sunpos, i, centerpos+Poffs, R, b, col); --- 137,153 ---- for ( i = 0; i < planetmap->Nsub; ++i ) { Vector2 Poffs; int col; ! double R; ! ! double b = b_default; ! Vector2 P; ! P = planetmap->sub[i]->position; ! ellipsparams(P - centerpos, b, ! R, Poffs, col); int k; k = planetmap->sub[i]->type; ! solarbody = new SolarBody(0, P, 0.0, moonspr[k], centerpos+relplanetpos, i, centerpos+Poffs, R, b, col); *************** *** 217,239 **** ! // define another (sub)menu ! ! Tedit = new Popup("gamex/interface/planetview/edit", 400, 200, game_screen); ! ! bdec = new Button(Tedit, "dec_"); ! binc = new Button(Tedit, "inc_"); ! bselect = new Button(Tedit, "select_"); ! bcancel = new Button(Tedit, "cancel_"); ! bplot = new Button(Tedit, "plot_"); T->add(Tedit); T->tree_doneinit(); ! Tedit->hide(); ! unscare_mouse(); ! show_mouse(game_screen); } --- 189,219 ---- + // stuff for the map editor ! SpaceSprite *mousespr; ! mousespr = create_sprite( "gamex/mouse/pointer_starmap.bmp", SpaceSprite::MASKED ); ! ptr = new MousePtr (mousespr); ! add(ptr); + Tedit = new IconTV("gamex/interface/starmap/edit", 400, 200, game_screen); + Tedit->exclusive = false; + bnew = new Button(Tedit, "new_"); + breplace = new Button(Tedit, "replace_"); + Tedit->setsprites(moonspr, moontypelist->N); T->add(Tedit); T->tree_doneinit(); ! Tedit->show(); ! Tedit->focus(); ! Tedit->layer = 1; // shown first ! T->layer = 2; // always shown later ! mapeditor = new MapEditor2(); ! mapeditor->set_game(this, ptr); ! mapeditor->set_interface( Tedit, breplace, bnew ); ! mapeditor->set_mapinfo( planetmap, 3, 1.0); ! ! mapeditor->mapcenter = centerpos; } *************** *** 257,260 **** --- 237,246 ---- playerinfo.sync(player); + if (mapeditor->maphaschanged) + { + // write the map to disk + mapeverything.save("gamex/mapinfo.txt"); + } + GameBare::quit(); } *************** *** 275,280 **** return; - double t = get_time2(); - GameBare::calculate(); --- 261,264 ---- *************** *** 313,318 **** */ ! t = get_time2() - t;// - paused_time; ! tic_history->add_element(pow(t, 4.0)); } --- 297,306 ---- */ ! ! // editor stuff ! ! ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); ! mapeditor->calculate(); ! } Index: gameplanetview.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetview.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gameplanetview.h 14 Dec 2003 14:20:58 -0000 1.4 --- gameplanetview.h 19 Dec 2003 08:52:54 -0000 1.5 *************** *** 24,31 **** class GamePlanetview : public GameBare { ! TWindow *Tedit; ! // contents of Tedit ! Button *bdec, *binc, *bselect, *bcancel, *bplot; //WindowInfo wininfo; --- 24,36 ---- class GamePlanetview : public GameBare { ! IconTV *Tedit; // contents of Tedit ! Button *bnew, *breplace; ! //int istarselect; ! ! MapEditor2 *mapeditor; ! ! MousePtr *ptr; ! //WindowInfo wininfo; Index: gameproject.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gameproject.cpp 15 Dec 2003 20:51:12 -0000 1.5 --- gameproject.cpp 19 Dec 2003 08:52:54 -0000 1.6 *************** *** 179,182 **** --- 179,185 ---- render_history = new Histograph(128); ti = true; + + // enable mouse drawing using the allegro pointer. + hideallegromouse = false; } *************** *** 257,264 **** double t = get_time2(); - ::space_zoom = wininfo.zoomlevel; - ::space_center = wininfo.mapcenter; - ::space_view_size = wininfo.framesize; - tempframe->full_redraw = true; FULL_REDRAW = true; --- 260,263 ---- *************** *** 271,282 **** acquire_bitmap(game_screen); if (T && !next) { ! T->tree_setscreen(game_screen); // game_screen can change value... T->tree_animate(); } release_bitmap(game_screen); ! show_mouse(game_screen); // when drawing is finished, you could do a page flip to the new screen. --- 270,295 ---- acquire_bitmap(game_screen); + acquire_bitmap(game_screen2); if (T && !next) { ! if (usepageflip) ! T->tree_setscreen(game_screen); // game_screen can change value... ! else ! T->tree_setscreen(game_screen2); // use a temp video area ! T->tree_animate(); } + + // extra action: draw the temp bitmap into the screen area + if (!usepageflip) + blit(game_screen2, game_screen, 0, 0, 0, 0, game_screen->w, game_screen->h); + + release_bitmap(game_screen2); release_bitmap(game_screen); ! if (!hideallegromouse) ! show_mouse(game_screen); ! else ! show_mouse(0); // when drawing is finished, you could do a page flip to the new screen. *************** *** 599,602 **** --- 612,619 ---- void GameBare::calculate() { + ::space_zoom = wininfo.zoomlevel; + ::space_center = wininfo.mapcenter; + ::space_view_size = wininfo.framesize; + int i; for (i = 0; i < num_items; i += 1) { Index: gameproject.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gameproject.h 15 Dec 2003 20:51:12 -0000 1.5 --- gameproject.h 19 Dec 2003 08:52:54 -0000 1.6 *************** *** 79,82 **** --- 79,83 ---- VideoWindow *window; + bool hideallegromouse; virtual void animate(); virtual void animate(Frame *frame); Index: gamesolarview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamesolarview.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamesolarview.cpp 15 Dec 2003 20:51:12 -0000 1.3 --- gamesolarview.cpp 19 Dec 2003 08:52:54 -0000 1.4 *************** *** 21,24 **** --- 21,142 ---- + + + void ellipsparams(Vector2 relpos, double ellb, + double &R, Vector2 &Poffs, int &col) + { + //double R; + double b_sqrt; + + + b_sqrt = sqrt(ellb); + + // pure ellips that hits the point has radius R + // Vector2 relpos; + // relpos = pos - 0.5*map_size; + relpos.y *= b_sqrt; + + double offs = 0.5; // offset of the ellips + double a; + a = offs * offs - 1; + + double b; + b = -2 * offs * relpos.y; + + double c; + c = magnitude_sqr(relpos); + + // solve quadr. eq. + double det; + det = b*b - 4*a*c; + if (det < 0) + { + tw_error("negative value for ellips root"); + } + det = sqrt(det); + + // two solutions: + double r1, r2; + r1 = (-b + det) / (2*a); + r2 = (-b - det) / (2*a); + + if (r1 > 0) + R = r1; + else + R = r2; + + // shift the ellips down (so, scale y-size down, hence R is scaled linearly cause y~Rsin(a)) + Poffs = Vector2(0, offs * R / b_sqrt); + //R *= 0.75; + + + //int col; + if (R < 500.0) + col = makecol(115,0,0); + else if (R < 1000.0) + col = makecol(0,85,0); + else if (R < 1500.0) + col = makecol(0,44,66); + else + col = makecol(0,0,115); + } + + + + + MapObj *MapEditor2::create_mapobj(Vector2 pos) + { + + + Vector2 Poffs; + int col; + double R; + + double b = b_default; + ellipsparams(pos - mapcenter, b, + R, Poffs, col); + + SolarBody *s; + + s = new SolarBody(0, pos, 0.0, Tedit->showspr(), mapcenter, Tedit->isel, + mapcenter+Poffs, R, b, col // ellips information + ); + + return s; + } + + + void MapEditor2::calculate() + { + MapEditor::calculate(); + + if (selection && moveselection) + { + + + SolarBody *s; + s = (SolarBody*) selection; + + s->stayhere = s->pos; // in this case, movement is allowed ... + + Vector2 Poffs; + int col; + double R; + + ellipsparams(s->pos - mapcenter, s->ellipsb, + R, Poffs, col); + + s->ellipsR = R; + s->ellipscol = col; + s->ellipscenter = mapcenter + Poffs; + + s->drawshadow(); + } + } + + + + + void GameSolarview::init_menu() { *************** *** 67,71 **** Vector2 sunpos; ! sunpos = 0.5 * size; // load the star data --- 185,189 ---- Vector2 sunpos; ! sunpos = Vector2(0.5, 0.25) * size; // load the star data *************** *** 79,82 **** --- 197,201 ---- // since the stars are already referenced (and edited?) therein... add(solarbody); + solarbody->id = 0; // cause it's not a editable map object... // the star is untouchable. *************** *** 97,129 **** for ( i = 0; i < solarmap->Nsub; ++i ) { - // "position" is in this case, the angular position, x=angle, y=r (in percentage of map size). - - double R, angle, b, b_sqrt; - - R = solarmap->sub[i]->position.y * 0.5*size.x; - angle = (PI/180) * solarmap->sub[i]->position.x; - - b = 2.0; - b_sqrt = sqrt(b); - Vector2 Poffs; - Poffs = Vector2(0, 0.25 * R/b_sqrt); - - Vector2 P; - P = sunpos + Poffs + R*Vector2(cos(angle), (1/b_sqrt)*sin(angle)); - int col; ! if (R < 500.0) ! col = makecol(115,0,0); ! else if (R < 1000.0) ! col = makecol(0,85,0); ! else if (R < 1500.0) ! col = makecol(0,44,66); ! else ! col = makecol(0,0,115); int k; k = solarmap->sub[i]->type; ! solarbody = new SolarBody(0, P, 0.0, planetspr[k], sunpos, i, sunpos+Poffs, R, b, col // ellips information ); --- 216,231 ---- for ( i = 0; i < solarmap->Nsub; ++i ) { Vector2 Poffs; int col; ! double R; ! ! double b = b_default; ! ellipsparams(solarmap->sub[i]->position - sunpos, b, ! R, Poffs, col); int k; k = solarmap->sub[i]->type; ! ! solarbody = new SolarBody(0, solarmap->sub[i]->position, 0.0, planetspr[k], sunpos, k, sunpos+Poffs, R, b, col // ellips information ); *************** *** 146,149 **** --- 248,280 ---- b->init(100, view->frame); add(b); + + + // stuff for the map editor + + SpaceSprite *mousespr; + mousespr = create_sprite( "gamex/mouse/pointer_starmap.bmp", SpaceSprite::MASKED ); + ptr = new MousePtr (mousespr); + add(ptr); + + Tedit = new IconTV("gamex/interface/starmap/edit", 400, 200, game_screen); + Tedit->exclusive = false; + bnew = new Button(Tedit, "new_"); + breplace = new Button(Tedit, "replace_"); + Tedit->setsprites(planetspr, planettypelist->N); + + T->add(Tedit); + T->tree_doneinit(); + + Tedit->show(); + Tedit->focus(); + Tedit->layer = 1; // shown first + T->layer = 2; // always shown later + + mapeditor = new MapEditor2(); + mapeditor->set_game(this, ptr); + mapeditor->set_interface( Tedit, breplace, bnew ); + mapeditor->set_mapinfo( solarmap, 2, 1.0); + + mapeditor->mapcenter = sunpos; } *************** *** 166,169 **** --- 297,307 ---- playerinfo.sync(player); + + if (mapeditor->maphaschanged) + { + // write the map to disk + mapeverything.save("gamex/mapinfo.txt"); + } + GameBare::quit(); } *************** *** 185,190 **** --- 323,334 ---- return; + double q; + wininfo.center(player->pos); + wininfo.edgecorrect(); + GameBare::calculate(); + q = space_zoom; + if (!(player && player->exists())) { *************** *** 211,216 **** wininfo.zoom(1 / (1 + 1*dt)); ! wininfo.center(player->pos); ! wininfo.edgecorrect(); } --- 355,363 ---- wininfo.zoom(1 / (1 + 1*dt)); ! ! // editor stuff ! ! ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); ! mapeditor->calculate(); } *************** *** 226,230 **** // only activate planet view mode, if you've hit a planet. ! if (player->collisionwith->id == ID_SOLAR_BODY) { --- 373,377 ---- // only activate planet view mode, if you've hit a planet. ! if (player->collisionwith->id == MAPOBJ_ID) { *************** *** 233,237 **** // which planet did you collide with ?! ! playerinfo.iplanet = ((SolarBody*) player->collisionwith)->solar_body_num; playerinfo.angle = player->angle; --- 380,384 ---- // which planet did you collide with ?! ! playerinfo.iplanet = ((SolarBody*) player->collisionwith)->starnum; playerinfo.angle = player->angle; *************** *** 253,262 **** if (next) return; - - // FULL_REDRAW = 1; - - // ::space_zoom = wininfo.zoomlevel; - // ::space_center = wininfo.mapcenter; - GameBare::animate(frame); --- 400,403 ---- Index: gamesolarview.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamesolarview.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamesolarview.h 14 Dec 2003 14:20:58 -0000 1.2 --- gamesolarview.h 19 Dec 2003 08:52:54 -0000 1.3 *************** *** 7,15 **** #include "gamegeneral.h" class GameSolarview : public GameBare { - //WindowInfo wininfo; class ThePlaya : public LocalPlayerInfo --- 7,46 ---- #include "gamegeneral.h" + #include "../twgui/twbuttontypes.h" + #include "../twgui/twpopup.h" + + #include "stuff/space_body.h" + + #include "gamesolarview.h" + + + // ellipticity + const double b_default = 4.0; + + // derive ellips R from position + extern void ellipsparams(Vector2 relpos, double ellb, double &R, Vector2 &Poffs, int &col); + + + class MapEditor2 : public MapEditor + { + public: + Vector2 mapcenter; + + virtual MapObj *create_mapobj(Vector2 pos); + virtual void calculate(); + }; + class GameSolarview : public GameBare { + IconTV *Tedit; + // contents of Tedit + Button *bnew, *breplace; + //int istarselect; + + MapEditor2 *mapeditor; + + MousePtr *ptr; class ThePlaya : public LocalPlayerInfo Index: gamestarmap.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamestarmap.cpp 15 Dec 2003 20:51:12 -0000 1.4 --- gamestarmap.cpp 19 Dec 2003 08:52:54 -0000 1.5 *************** *** 17,50 **** #include "gamestarmap.h" - #include "../twgui/twpopup.h" - - - - - - - Star::Star(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite) - : - SpaceObject(creator, opos, oangle, osprite) - { - id = STAR_ID; - layer = LAYER_SHOTS; - } - - void Star::animate(Frame *f) - { - //SpaceObject::animate(f); - //sprite->animate(pos, sprite_index, f); - Vector2 s = sprite->size(sprite_index); - double scale = space_zoom; - if (scale < 0.25) - scale = 0.25; - sprite->draw(corner(pos, s ), s * scale, sprite_index, f); - } - - void Star::calculate() - { - SpaceObject::calculate(); - } --- 17,20 ---- *************** *** 97,105 **** for ( i = 0; i < starmap->Nsub; ++i ) { ! Star *star; int k; k = starmap->sub[i]->type; ! star = new Star(0, starmap->sub[i]->position * scalepos, 0.0, starspr[k]); star->starnum = i; --- 67,75 ---- for ( i = 0; i < starmap->Nsub; ++i ) { ! MapObj *star; int k; k = starmap->sub[i]->type; ! star = new MapObj(0, starmap->sub[i]->position * scalepos, 0.0, starspr[k]); star->starnum = i; *************** *** 122,287 **** keyper = new Periodics(0.1); ! selectionstar = 0; ! lastselectionstar = 0; ! maphaschanged = false; // check if the map changed; if so, it's to be written back to disk // define another (sub)menu ! Tedit = new Popup("gamex/interface/starmap/edit", 400, 200, game_screen); ! Tedit->exclusive = true; ! ! ! bdec = new Button(Tedit, "dec_"); ! binc = new Button(Tedit, "inc_"); bnew = new Button(Tedit, "new_"); breplace = new Button(Tedit, "replace_"); ! bplot = new Button(Tedit, "plot_"); - istarselect = 0; - update_bplot(); T->add(Tedit); T->tree_doneinit(); - } ! void GameStarmap::update_bplot() ! { ! BITMAP *dest, *src; ! src = starspr[istarselect]->get_bitmap(0); ! dest = bplot->bmp_default; ! clear_to_color(dest, 0); ! blit(src, dest, 0, 0, 0, 0, src->w, src->h); } - void GameStarmap::mapeditor_stuff() - { - // keep track of the last star that was clicked on by the mouse - if (ptr->selection && (ptr->selection->id == STAR_ID)) - { - Star *star = (Star*) ptr->selection; - lastselectionstar = star; - } - - - // move a star - if (selectionstar) - { - - selectionstar->pos = ptr->pos; - staywithin(0, &(selectionstar->pos), map_size); - } - - - // delete a star - if (selectionstar && keyhandler.keyhit[KEY_DEL]) - { - // remove from game physics - remove(selectionstar); - - // remove from the map - starmap->rem(selectionstar->starnum); - - - // remove from memory - delete selectionstar; - - selectionstar = 0; - } - - - // place a star - if ( selectionstar && maparea->flag.left_mouse_press )//(mouse_b & 1) ) - { - // update the map with this star ? - // yep ... - int k; - k = selectionstar->starnum; - starmap->sub[k]->position = selectionstar->pos / scalepos; - - - // make sure it's not edited anymore - selectionstar = 0; - - maphaschanged = true; - - maparea->flag.left_mouse_press = false; // cause you've used it now - } - - - // select a star for movement (or so ...) - //if ( (!selectionstar) && key[KEY_LCONTROL] && lastselectionstar) - // using left-click of the mouse on the starmap area of the menu - if ( (!selectionstar) && lastselectionstar && maparea->flag.left_mouse_press ) - { - selectionstar = lastselectionstar; - - maparea->flag.left_mouse_press = false; - } - - - - // --------------- - - // by pressing "space", you initialize the menu - if (keyhandler.keyhit[KEY_SPACE]) - { - Tedit->show(); - Tedit->center_abs(mouse_x, mouse_y); - } - - if (breplace->flag.left_mouse_press) - { - Tedit->hide(); - T->show(); - - // change the picture of the selected star - if (selectionstar) - { - int k; - k = selectionstar->starnum; - starmap->sub[k]->type = istarselect; - selectionstar->set_sprite(starspr[istarselect]); - } - } - - if (bnew->flag.left_mouse_press) - { - Tedit->hide(); - T->show(); - - // select this picture for a new star ? - if (!selectionstar) - { - selectionstar = new Star(0, 0, 0, starspr[istarselect]); - add(selectionstar); - - // also ... add it to the map ?? with default settings .. - selectionstar->starnum = starmap->add(1); // level 1 = stars - - } - } - - if (binc->flag.left_mouse_press || bdec->flag.left_mouse_press) - { - if (binc->flag.left_mouse_press) - ++istarselect; - - if (bdec->flag.left_mouse_press) - --istarselect; - - if (istarselect < 0 ) - istarselect = startypelist->N - 1; - - if (istarselect >= startypelist->N) - istarselect = 0; - - update_bplot(); - - } - } void GameStarmap::calculate() --- 92,125 ---- keyper = new Periodics(0.1); ! // selectionstar = 0; ! // lastselectionstar = 0; ! // maphaschanged = false; // check if the map changed; if so, it's to be written back to disk // define another (sub)menu ! Tedit = new IconTV("gamex/interface/starmap/edit", 400, 200, game_screen); ! Tedit->exclusive = false; bnew = new Button(Tedit, "new_"); breplace = new Button(Tedit, "replace_"); ! Tedit->setsprites(starspr, startypelist->N); T->add(Tedit); T->tree_doneinit(); + Tedit->show(); + Tedit->focus(); + Tedit->layer = 1; // shown first + T->layer = 2; // always shown later ! mapeditor = new MapEditor(); ! mapeditor->set_game(this, ptr); ! mapeditor->set_interface( Tedit, breplace, bnew ); ! mapeditor->set_mapinfo( starmap, 1, scalepos); } void GameStarmap::calculate() *************** *** 290,302 **** return; ! ::space_view_size = wininfo.framesize; ! ::space_zoom = wininfo.zoomlevel; ! ::space_center = wininfo.mapcenter; ! ! ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); GameBare::calculate(); if ( mouseper->update() && (mouse_b & 2) ) { --- 128,140 ---- return; ! //::space_view_size = wininfo.framesize; ! //::space_zoom = wininfo.zoomlevel; ! //::space_center = wininfo.mapcenter; GameBare::calculate(); + ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); + if ( mouseper->update() && (mouse_b & 2) ) { *************** *** 317,322 **** ! mapeditor_stuff(); } --- 155,166 ---- ! mapeditor->calculate(); ! ! } + Vector2 corner2 ( Vector2 pos, Vector2 size ) {STACKTRACE + pos -= space_center; + pos -= size / 2; + return pos * space_zoom + space_view_size / 2; } *************** *** 327,335 **** return; - ::space_zoom = wininfo.zoomlevel; - ::space_center = wininfo.mapcenter; GameBare::animate(frame); } --- 171,211 ---- return; + if (ptr->pos.x == 0 || ptr->pos.y == 0 || !maparea->hasmouse()) + hideallegromouse = false; + else if (Tedit->grabbedmouse) + hideallegromouse = false; + else + hideallegromouse = true; + + + // draw a grid ... + int ix, iy; + Vector2 P1, P2; + + int c; + c = makecol(128, 64, 0); + + for ( iy = 0; iy < 11; ++iy ) + { + P1 = corner2( Vector2( 0, iy*10000), 0); + P2 = corner2( Vector2(100000, iy*10000), 0); + + hline(frame->surface, P1.x, P1.y, P2.x, c); + } + + for ( ix = 0; ix < 11; ++ix ) + { + P1 = corner2( Vector2(ix*10000, 0), 0); + P2 = corner2( Vector2(ix*10000, 100000), 0); + + vline(frame->surface, P1.x, P1.y, P2.y, c); + } + + + // draw the stars GameBare::animate(frame); + } *************** *** 354,358 **** delete starspr[i]; ! if (maphaschanged) { // write the map to disk --- 230,234 ---- delete starspr[i]; ! if (mapeditor->maphaschanged) { // write the map to disk Index: gamestarmap.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamestarmap.h 15 Dec 2003 20:51:12 -0000 1.4 --- gamestarmap.h 19 Dec 2003 08:52:54 -0000 1.5 *************** *** 8,25 **** #include "gamegeneral.h" - const int STAR_ID = 0x08fa51d3; - class Star : public SpaceObject - { - public: - int starnum; - Star(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite); - virtual void animate(Frame *f); - virtual void calculate(); - }; --- 8,20 ---- #include "gamegeneral.h" + #include "../twgui/twbuttontypes.h" + #include "../twgui/twpopup.h" + + #include "stuff/space_body.h" *************** *** 29,39 **** public: ! TWindow *Tedit; // contents of Tedit ! Button *bdec, *binc, *bnew, *breplace, *bplot; ! int istarselect; double scalepos; ! Star *selectionstar, *lastselectionstar; Periodics *mouseper, *keyper; --- 24,36 ---- public: ! IconTV *Tedit; // contents of Tedit ! Button *bnew, *breplace; ! //int istarselect; ! ! MapEditor *mapeditor; double scalepos; ! //MapObj *selectionstar, *lastselectionstar; Periodics *mouseper, *keyper; *************** *** 62,69 **** SpaceSprite *starspr[32], *playerspr; ! bool maphaschanged; ! void update_bplot(); ! void mapeditor_stuff(); }; --- 59,66 ---- SpaceSprite *starspr[32], *playerspr; ! //bool maphaschanged; ! // void update_bplot(); ! //void mapeditor_stuff(); }; Index: projectx.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/projectx.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** projectx.cpp 15 Dec 2003 20:51:12 -0000 1.5 --- projectx.cpp 19 Dec 2003 08:52:54 -0000 1.6 *************** *** 77,81 **** // add( new GameStarmap() ); ! // add( new GamePlanetview() ); // add( new GamePlanetscan() ); // add( new GameMelee() ); --- 77,82 ---- // add( new GameStarmap() ); ! // add( new GameSolarview() ); ! add( new GamePlanetview() ); // add( new GamePlanetscan() ); // add( new GameMelee() ); |
From: <geo...@us...> - 2003-12-19 08:52:57
|
Update of /cvsroot/timewarp/source/twgui In directory sc8-pr-cvs1:/tmp/cvs-serv29070/twgui Modified Files: twbuttontypes.cpp twbuttontypes.h twwindow.cpp twwindow.h Log Message: map editing Index: twbuttontypes.cpp =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twbuttontypes.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** twbuttontypes.cpp 15 Dec 2003 20:51:12 -0000 1.2 --- twbuttontypes.cpp 19 Dec 2003 08:52:54 -0000 1.3 *************** *** 81,84 **** --- 81,86 ---- { init_pos_size(&backgr, "backgr"); + + markfordeletion = true; } *************** *** 86,90 **** Area::~Area() { ! if (backgr) destroy_bitmap(backgr); } --- 88,92 ---- Area::~Area() { ! if (markfordeletion && backgr) destroy_bitmap(backgr); } *************** *** 97,102 **** if (newb) { ! destroy_bitmap(backgr); backgr = newb; } } --- 99,120 ---- if (newb) { ! if (markfordeletion && backgr) ! destroy_bitmap(backgr); ! ! backgr = newb; ! markfordeletion = true; // locally initialized, hence locally destroyed... ! } ! } ! ! ! void Area::changebackgr(BITMAP *newb) ! { ! if (newb) ! { ! if (markfordeletion && backgr) ! destroy_bitmap(backgr); // hmm, well, don't do this, leave that to the program that created it !! ! backgr = newb; + markfordeletion = false; // not locally initialized, hence not locally destroyed... } } Index: twbuttontypes.h =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twbuttontypes.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** twbuttontypes.h 15 Dec 2003 20:51:12 -0000 1.4 --- twbuttontypes.h 19 Dec 2003 08:52:54 -0000 1.5 *************** *** 36,39 **** --- 36,40 ---- public: BITMAP *backgr; + bool markfordeletion; Area(TWindow *menu, char *identbranch, int asciicode = 0, bool akeepkey = 0); *************** *** 41,44 **** --- 42,46 ---- virtual void changebackgr(char *fname); + virtual void changebackgr(BITMAP *newb); virtual void animate(); // shouldn't be changed. Index: twwindow.cpp =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twwindow.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** twwindow.cpp 15 Dec 2003 20:51:12 -0000 1.4 --- twwindow.cpp 19 Dec 2003 08:52:54 -0000 1.5 *************** *** 141,144 **** --- 141,145 ---- exclusive = false; + layer = 0; } // ok, this provides a working space *************** *** 259,262 **** --- 260,270 ---- root = tree_root(); + // check layers, you're not allowed to focus in a "lower" layer + while (root && root->layer < layer) + root = root->next; + + if (!root || root == this) // apparently you're alone/ already focus in your own layer ... + return; + // remove "this" from the list if (prev) *************** *** 675,679 **** // also copy transparent color! ! // this takes about 1 ms blit(backgr, drawarea, 0, 0, 0, 0, W, H); --- 683,687 ---- // also copy transparent color! ! // this takes about 1 ms on geo's comp if it's in video mem blit(backgr, drawarea, 0, 0, 0, 0, W, H); *************** *** 683,688 **** while (button) { - // "hyperspace" --> this takes 10 ms !! That's a lot for just that bitmap ... - // it's slow cause it goes from RAM to video-memory. button->animate(); button = button->next; --- 691,694 ---- *************** *** 694,698 **** if (screen) { ! // this takes about 2 ms. masked_blit(drawarea, screen, 0, 0, x, y, W, H); } --- 700,704 ---- if (screen) { ! // this takes about 2 ms on geo's comp if it's in video mem masked_blit(drawarea, screen, 0, 0, x, y, W, H); } Index: twwindow.h =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twwindow.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** twwindow.h 14 Dec 2003 22:19:56 -0000 1.3 --- twwindow.h 19 Dec 2003 08:52:54 -0000 1.4 *************** *** 10,13 **** --- 10,18 ---- + exclusive = when focused, all other windows are disabled. Default=false. + layer = you can only change focus within your own layer. Default=0. In this way you can cause a set of windows to always appear above another set of windows. + disabled = that window does no calculate (use ... to do this ?) + hidden = that window does not animate (use hide() to stop activity, or show() to restore activity) + */ *************** *** 134,137 **** --- 139,143 ---- bool exclusive; + int layer; // you can only switch focus within a layer... }; |
From: <geo...@us...> - 2003-12-19 08:52:57
|
Update of /cvsroot/timewarp/source/gamex/stuff In directory sc8-pr-cvs1:/tmp/cvs-serv29070/gamex/stuff Modified Files: space_body.cpp space_body.h Log Message: map editing Index: space_body.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/stuff/space_body.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** space_body.cpp 18 Nov 2003 17:18:52 -0000 1.1.1.1 --- space_body.cpp 19 Dec 2003 08:52:54 -0000 1.2 *************** *** 22,26 **** R *= space_zoom; //center = (center - space_center) * space_zoom + space_view_size/2; ! center = corner(center); int xref, yref, jbest; --- 22,29 ---- R *= space_zoom; //center = (center - space_center) * space_zoom + space_view_size/2; ! // center = corner(center); ! // the "corner" goes wrong, if you have very large ellipses (eg of a sun far away) ! // therefore, use the unwrapped version like this: ! center = (center - space_center) * space_zoom + space_view_size/2; int xref, yref, jbest; *************** *** 230,238 **** ! SolarBody::SolarBody(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite, Vector2 sunpos, int bodynum, Vector2 Ec, double ER, double Eb, int Ecol) : ! SpaceObject(creator, opos, oangle, osprite) { layer = LAYER_SHOTS; --- 233,503 ---- ! ! ! ! ! ! ! /* ! mapeditor: ! ! +/- zoom in/out on the map ! ! right-click = navigate on the map (becomes the new focus) ! ! left-click = select another star (stays fixed) ! ctrl = press, make the star follow the cursor, press again to fix it to the new position ! ! use the menu to replace star-type, or create a new star. ! ! */ ! ! ! ! MapEditor::MapEditor() ! { ! maphaschanged = false; ! ! objmap = 0; ! selection = 0; ! //lastselection = 0; ! ! Tedit = 0; ! bnew = 0; ! breplace = 0; ! ! maplevel = 0; ! ! scalepos = 0; ! ! moveselection = false; ! } ! ! MapEditor::~MapEditor() ! { ! } ! ! ! ! void MapEditor::set_game(GameBare *agame, MousePtr *aptr) ! { ! g = agame; ! ptr = aptr; ! } ! ! ! ! void MapEditor::set_interface( IconTV *aTedit, Button *abreplace, Button *abnew ) ! { ! Tedit = aTedit; ! breplace = abreplace; ! bnew = abnew; ! } ! ! void MapEditor::set_mapinfo( MapSpacebody *aobjmap, int amaplevel, double ascalepos) ! { ! objmap = aobjmap; ! maplevel = amaplevel; ! scalepos = ascalepos; ! } ! ! ! MapObj *MapEditor::create_mapobj(Vector2 pos) ! { ! return new MapObj(0, pos, 0, Tedit->showspr()); ! } ! ! ! void MapEditor::calculate() ! { ! // keep track of the last star that was clicked on by the mouse ! // if (ptr->selection && (ptr->selection->id == MAPOBJ_ID)) ! // lastselection = (MapObj*) ptr->selection; ! ! ! // move a star (only if CTRL is pressed) ! if ( keyhandler.keyhit[KEY_LCONTROL] ) ! moveselection = !moveselection; ! ! if (selection && moveselection) ! { ! selection->pos = ptr->pos; ! staywithin(0, &(selection->pos), map_size); ! ! ! int k; ! k = selection->starnum; ! objmap->sub[k]->position = selection->pos / scalepos; ! ! maphaschanged = true; ! } ! ! ! // delete a star ! if (selection && keyhandler.keyhit[KEY_DEL]) ! { ! // remove from game physics ! g->remove(selection); ! ! // remove from the map ! objmap->rem(selection->starnum); ! ! ! // remove from memory ! delete selection; ! ! selection = 0; ! } ! ! // select a star for movement (or so ...) ! // using left-click of the mouse on the starmap area of the menu ! // but only select map-objects that you can edit... ! if ( g->maparea->flag.left_mouse_press && !moveselection && ! ptr->selection && ptr->selection->id == MAPOBJ_ID) ! { ! selection = (MapObj*) ptr->selection; ! ! g->maparea->flag.left_mouse_press = false; ! } ! ! ! ! if (breplace->flag.left_mouse_press && !moveselection) ! { ! ! // change the picture of the selected star ! if (selection) ! { ! int k; ! k = selection->starnum; ! objmap->sub[k]->type = Tedit->isel; ! selection->set_sprite(Tedit->showspr()); ! } ! } ! ! if (bnew->flag.left_mouse_press && !moveselection) ! { ! // just make a new selection ! selection = create_mapobj(ptr->pos); ! g->add(selection); ! ! moveselection = true; ! ! // also ... add it to the map ?? with default settings .. ! selection->starnum = objmap->add(maplevel); // level 1 = stars ! ! int k; ! k = selection->starnum; ! objmap->sub[k]->type = Tedit->isel; ! selection->set_sprite(Tedit->showspr()); ! } ! ! } ! ! ! ! ! IconTV::IconTV(char *ident, int xcenter, int ycenter, BITMAP *outputscreen) ! : ! Popup(ident, xcenter, ycenter, outputscreen) ! { ! tv = new Area(this, "plot_"); ! bdec = new Button(this, "dec_"); ! binc = new Button(this, "inc_"); ! ! sprlist = 0; ! N = 0; ! isel = 0; ! } ! ! IconTV::~IconTV() ! { ! } ! ! ! void IconTV::setsprites(SpaceSprite **asprlist, int aN) ! { ! sprlist = asprlist; ! N = aN; ! ! isel = 0; ! ! tv->changebackgr(sprlist[0]->get_bitmap(0)); ! } ! ! ! void IconTV::calculate() ! { ! if (disabled) ! return; ! ! Popup::calculate(); ! ! if (bdec->flag.left_mouse_press || binc->flag.left_mouse_press) ! { ! if (binc->flag.left_mouse_press) ! ++isel; ! ! if (bdec->flag.left_mouse_press) ! --isel; ! ! if (isel < 0 ) ! isel = N-1; ! ! if (isel >= N) ! isel = 0; ! ! tv->changebackgr(sprlist[isel]->get_bitmap(0)); ! ! } ! } ! ! SpaceSprite *IconTV::showspr() ! { ! return sprlist[isel]; ! } ! ! ! ! ! ! ! // should be something like "star" perhaps ... it doesn't matter much, it's just a ! // sprite. ! ! MapObj::MapObj(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite) ! : ! SpaceObject(creator, opos, oangle, osprite) ! { ! id = MAPOBJ_ID; ! layer = LAYER_SHOTS; ! } ! ! void MapObj::animate(Frame *f) ! { ! //SpaceObject::animate(f); ! //sprite->animate(pos, sprite_index, f); ! Vector2 s = sprite->size(sprite_index); ! double scale = space_zoom; ! if (scale < 0.25) ! scale = 0.25; ! sprite->draw(corner(pos, s ), s * scale, sprite_index, f); ! } ! ! void MapObj::calculate() ! { ! SpaceObject::calculate(); ! } ! ! ! ! ! ! ! SolarBody::SolarBody(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite, Vector2 osunpos, int bodynum, Vector2 Ec, double ER, double Eb, int Ecol) : ! MapObj(creator, opos, oangle, osprite) { layer = LAYER_SHOTS; *************** *** 246,258 **** stayhere = pos; ! if (pos != sunpos) ! { ! sunangle = (pos - sunpos).atan(); ! shadowpaintcircle(sprite, sunangle); ! } ! id = ID_SOLAR_BODY; ! solar_body_num = bodynum; ellipscenter = Ec; --- 511,522 ---- stayhere = pos; + sunpos = osunpos; ! // copy the original sprite, cause it's going to be altered. ! sprite = 0; ! set_sprite(osprite); ! //id = ID_SOLAR_BODY; ! starnum = bodynum; ellipscenter = Ec; *************** *** 262,265 **** --- 526,535 ---- } + SolarBody::~SolarBody() + { + if (sprite) + delete sprite; + } + void SolarBody::animate(Frame *f) { *************** *** 278,281 **** --- 548,578 ---- } + void SolarBody::set_sprite(SpaceSprite *new_sprite) + { + if (sprite) + delete sprite; + + origsprite = new_sprite; + sprite = new SpaceSprite( *new_sprite ); + size = new_sprite->size(); + + drawshadow(); + } + + + void SolarBody::drawshadow() + { + BITMAP *dest, *src; + src = origsprite->get_bitmap(0); + dest = sprite->get_bitmap(0); + blit(src, dest, 0, 0, 0, 0, src->w, src->h); + + if (pos != sunpos) + { + sunangle = (pos - sunpos).atan(); + shadowpaintcircle(sprite, sunangle); + } + + } Index: space_body.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/stuff/space_body.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** space_body.h 18 Nov 2003 17:18:52 -0000 1.1.1.1 --- space_body.h 19 Dec 2003 08:52:54 -0000 1.2 *************** *** 9,15 **** void shadowpaintcircle(SpaceSprite *spr, double fi_s); ! const int ID_SOLAR_BODY = 0x098a398f5; ! class SolarBody : public SpaceObject { public: --- 9,100 ---- void shadowpaintcircle(SpaceSprite *spr, double fi_s); ! #include "../../twgui/twpopup.h" ! #include "../../twgui/twbuttontypes.h" ! #include "../gameproject.h" ! #include "../gamedata.h" ! ! class IconTV : public Popup ! { ! SpaceSprite **sprlist; ! int N; ! ! Area *tv; ! Button *bdec, *binc; ! public: ! ! int isel; ! ! IconTV(char *ident, int xcenter, int ycenter, BITMAP *outputscreen); ! virtual ~IconTV(); ! ! virtual void calculate(); ! ! void setsprites(SpaceSprite **asprlist, int aN); ! ! SpaceSprite *showspr(); ! }; ! ! ! ! ! const int MAPOBJ_ID = 0x08fa51d3; ! ! class MapObj : public SpaceObject ! { ! public: ! ! int starnum; ! ! MapObj(SpaceLocation *creator, Vector2 opos, double oangle, SpaceSprite *osprite); ! ! virtual void animate(Frame *f); ! virtual void calculate(); ! }; ! ! ! ! ! class MapEditor ! { ! protected: ! MapObj *selection;//*lastselection, ! ! GameBare *g; ! MousePtr *ptr; ! ! MapSpacebody *objmap; ! int maplevel; ! ! ! IconTV *Tedit; ! Button *breplace, *bnew; ! ! double scalepos; ! ! bool moveselection; ! ! public: ! bool maphaschanged; ! ! MapEditor(); ! virtual ~MapEditor(); ! ! virtual void calculate(); ! ! void set_game(GameBare *agame, MousePtr *aptr); ! void set_interface( IconTV *aTedit, Button *abreplace, Button *abnew ); ! void set_mapinfo( MapSpacebody *aobjmap, int amaplevel, double ascalepos); ! ! virtual MapObj *create_mapobj(Vector2 pos); ! }; ! ! ! ! ! ! //const int ID_SOLAR_BODY = 0x098a398f5; ! ! class SolarBody : public MapObj { public: *************** *** 19,31 **** int bodynum, Vector2 Ec, double ER, double Eb, int Ecol); virtual void animate(Frame *f); virtual void calculate(); ! int solar_body_num; Vector2 ellipscenter; double ellipsR, ellipsb; int ellipscol; }; --- 104,126 ---- int bodynum, Vector2 Ec, double ER, double Eb, int Ecol); + virtual ~SolarBody(); virtual void animate(Frame *f); virtual void calculate(); ! // int solar_body_num; ! ! SpaceSprite *origsprite; ! Vector2 sunpos; Vector2 ellipscenter; double ellipsR, ellipsb; int ellipscol; + + virtual void set_sprite ( SpaceSprite *sprite ); + void drawshadow(); }; + + + |
From: <geo...@us...> - 2003-12-15 20:51:15
|
Update of /cvsroot/timewarp/source/gamex In directory sc8-pr-cvs1:/tmp/cvs-serv22001/gamex Modified Files: gamegeneral.cpp gamegeneral.h gamehyper.cpp gamehyper.h gamemelee.cpp gameplanetview.cpp gameproject.cpp gameproject.h gamesolarview.cpp gamestarmap.cpp gamestarmap.h projectx.cpp Log Message: fixed a mistake in the fg-game animate, and stuffed bitmaps in video-memory, which can be a big improvement... also, discarded use of page-flips cause that waits for a retrace (idle for 8 ms). Index: gamegeneral.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamegeneral.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gamegeneral.cpp 14 Dec 2003 22:19:55 -0000 1.4 --- gamegeneral.cpp 15 Dec 2003 20:51:12 -0000 1.5 *************** *** 12,15 **** --- 12,33 ---- + void makevideobmp(BITMAP *&bmp) + { + BITMAP *newbmp; + int w, h; + + w = bmp->w; + h = bmp->h; + + newbmp = create_video_bitmap(w, h); + + if (newbmp) + { + destroy_bitmap(bmp); + bmp = newbmp; + } + } + + /* // to be used by the game: it's a preprocessing operation *************** *** 70,74 **** ! SpaceSprite *create_sprite(char *bmpfilename, int _attributes, int rotations, int bpp, double scale ) { RGB pal[256]; --- 88,92 ---- ! SpaceSprite *create_sprite(char *bmpfilename, int _attributes, int rotations, int bpp, double scale, bool vidmem ) { RGB pal[256]; *************** *** 89,93 **** // load the bitmap data in the correct color depth (since then you // can use the masked_blit operation without problems). ! bmplist[i] = create_bitmap_ex(bpp, tmpbmp->w, tmpbmp->h); blit(tmpbmp, bmplist[i], 0, 0, 0, 0, tmpbmp->w, tmpbmp->h); destroy_bitmap(tmpbmp); --- 107,116 ---- // load the bitmap data in the correct color depth (since then you // can use the masked_blit operation without problems). ! bmplist[i] = 0; ! if (vidmem) ! create_video_bitmap(tmpbmp->w, tmpbmp->h); ! if (!bmplist[i]) ! bmplist[i] = create_bitmap_ex(bpp, tmpbmp->w, tmpbmp->h); ! blit(tmpbmp, bmplist[i], 0, 0, 0, 0, tmpbmp->w, tmpbmp->h); destroy_bitmap(tmpbmp); *************** *** 95,99 **** if (scale != 1) { ! tmpbmp = create_bitmap_ex(bpp, bmplist[i]->w * scale, bmplist[i]->h * scale); stretch_blit(bmplist[i], tmpbmp, 0, 0, bmplist[i]->w, bmplist[i]->h, 0, 0, tmpbmp->w, tmpbmp->h); --- 118,126 ---- if (scale != 1) { ! if (vidmem) ! tmpbmp = create_video_bitmap(bmplist[i]->w * scale, bmplist[i]->h * scale); ! else ! tmpbmp = create_bitmap_ex(bpp, bmplist[i]->w * scale, bmplist[i]->h * scale); ! stretch_blit(bmplist[i], tmpbmp, 0, 0, bmplist[i]->w, bmplist[i]->h, 0, 0, tmpbmp->w, tmpbmp->h); Index: gamegeneral.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamegeneral.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamegeneral.h 14 Dec 2003 22:19:55 -0000 1.2 --- gamegeneral.h 15 Dec 2003 20:51:12 -0000 1.3 *************** *** 7,10 **** --- 7,12 ---- void replace_color(BITMAP *bmp, int col1, int col2); + void makevideobmp(BITMAP *&bmp); + class MousePtr : public SpaceObject *************** *** 58,62 **** //SpaceSprite *create_sprite(char *bmpfilename, int _attributes); ! SpaceSprite *create_sprite(char *bmpfilename, int _attributes, int rotations = 1, int bpp=32, double scale = 1); --- 60,64 ---- //SpaceSprite *create_sprite(char *bmpfilename, int _attributes); ! SpaceSprite *create_sprite(char *bmpfilename, int _attributes, int rotations = 1, int bpp=32, double scale = 1, bool vidmem = false); Index: gamehyper.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamehyper.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamehyper.cpp 14 Dec 2003 14:20:58 -0000 1.2 --- gamehyper.cpp 15 Dec 2003 20:51:12 -0000 1.3 *************** *** 79,82 **** --- 79,83 ---- void AnimationHyper::animate(Frame *space) { + // scale = 1; // sprite->animate(pos, sprite_index, space, scale); *************** *** 202,206 **** int bpp; bpp = bitmap_color_depth(bmp); ! bmpcache[sprite_index] = create_bitmap_ex(bpp, s.x, s.y); stretch_blit(bmp, bmpcache[sprite_index], --- 203,208 ---- int bpp; bpp = bitmap_color_depth(bmp); ! //bmpcache[sprite_index] = create_bitmap_ex(bpp, s.x, s.y); ! bmpcache[sprite_index] = create_video_bitmap(s.x, s.y); // for faster drawing. stretch_blit(bmp, bmpcache[sprite_index], *************** *** 303,310 **** T = new TWindow("gamex/interface/hyperspace", 0, 0, game_screen, true); ! maparea = new AreaTablet(T, "map_"); ! bradar = new AreaTablet(T, "radar_"); } --- 305,314 ---- T = new TWindow("gamex/interface/hyperspace", 0, 0, game_screen, true); ! maparea = new Area(T, "map_"); ! makevideobmp(maparea->backgr); // for (much) faster drawing? Cause we're dealing with a large area here! ! bradar = new Area(T, "radar_"); ! makevideobmp(bradar->backgr); } *************** *** 457,461 **** // this defaults to a 32 bit depth (doh) !! ! spr[i] = create_sprite( sprname, SpaceSprite::MASKED | SpaceSprite::IRREGULAR, N, 32, sprscale ); //sprA = create_sprite( "gamex/hyperspace/star_blobA_01.bmp", SpaceSprite::MASKED | SpaceSprite::IRREGULAR, 6 ); //sprB = create_sprite( "gamex/hyperspace/star_blobB_01.bmp", SpaceSprite::MASKED | SpaceSprite::IRREGULAR, 6 ); --- 461,467 ---- // this defaults to a 32 bit depth (doh) !! ! bool vidmem = true; // try to store the sprites in video-memory, for speed ! // too bad; true or false makes no difference... ! spr[i] = create_sprite( sprname, SpaceSprite::MASKED | SpaceSprite::IRREGULAR, N, 32, sprscale, vidmem ); //sprA = create_sprite( "gamex/hyperspace/star_blobA_01.bmp", SpaceSprite::MASKED | SpaceSprite::IRREGULAR, 6 ); //sprB = create_sprite( "gamex/hyperspace/star_blobB_01.bmp", SpaceSprite::MASKED | SpaceSprite::IRREGULAR, 6 ); *************** *** 642,648 **** GameBare::animate(frame); - - - } --- 648,651 ---- Index: gamehyper.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamehyper.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamehyper.h 14 Dec 2003 14:20:58 -0000 1.2 --- gamehyper.h 15 Dec 2003 20:51:12 -0000 1.3 *************** *** 36,40 **** public: ! AreaTablet *bradar; MousePtr *ptr; --- 36,40 ---- public: ! Area *bradar; MousePtr *ptr; Index: gamemelee.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamemelee.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamemelee.cpp 14 Dec 2003 14:20:58 -0000 1.3 --- gamemelee.cpp 15 Dec 2003 20:51:12 -0000 1.4 *************** *** 107,111 **** T = new TWindow("gamex/interface/melee", 0, 0, game_screen, true); ! maparea = new AreaTablet(T, "map_"); } --- 107,111 ---- T = new TWindow("gamex/interface/melee", 0, 0, game_screen, true); ! maparea = new Area(T, "map_"); } Index: gameplanetview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameplanetview.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gameplanetview.cpp 14 Dec 2003 14:20:58 -0000 1.4 --- gameplanetview.cpp 15 Dec 2003 20:51:12 -0000 1.5 *************** *** 38,42 **** T = new TWindow("gamex/interface/planetview", 0, 0, game_screen, true); ! maparea = new AreaTablet(T, "map_"); } --- 38,42 ---- T = new TWindow("gamex/interface/planetview", 0, 0, game_screen, true); ! maparea = new Area(T, "map_"); } *************** *** 359,394 **** void GamePlanetview::animate() { - - //idle(20); - - /* - ::space_zoom = wininfo.zoomlevel; - ::space_center = wininfo.mapcenter; - ::space_view_size = wininfo.framesize; - - // override the use of the "default" screen, instead re-route everything to the - // menu bitmaps. - - tempframe->full_redraw = true; - FULL_REDRAW = true; - tempframe->erase(); - tempframe->prepare(); - - - // message.print(1500, 14, "%p %p %p", T->drawarea, T->backgr, ::screen); - - animate(tempframe); - - - - //T->tree_setscreen(game_screen); - T->tree_animate(); - */ - GameBare::animate(); - - - - //show_mouse(game_screen); } --- 359,363 ---- Index: gameproject.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gameproject.cpp 14 Dec 2003 22:19:55 -0000 1.4 --- gameproject.cpp 15 Dec 2003 20:51:12 -0000 1.5 *************** *** 224,237 **** Physics::animate(frame); - if (T && !prev) - { - T->tree_animate(); - } - // (and the game frame then draws to video memory?) if (ti) show_ticinfo(frame, tic_history, render_history, 4.0); - } --- 224,231 ---- *************** *** 243,278 **** return; ! // switch drawing screen ! if (game_screen == game_screen1) ! game_screen = game_screen2; ! else ! game_screen = game_screen1; ! //clear_to_color(game_screen, 0); ! ! /* ! ! int predtime = 0; ! ! Frame *f = view->frame; ! ! if (FULL_REDRAW) ! f->full_redraw = true; ! f->erase(); ! view->prepare(f, predtime); ! if (f->surface) { ! if (f->surface) ! animate(f); - //message.animate(frame); // displays messages that're stored somewhere - } - scare_mouse(); - f->draw(); - unscare_mouse(); - return; - */ double t = get_time2(); --- 237,257 ---- return; ! if (poll_scroll()) //in case you still have to wait for a page flip... ! return; ! bool usepageflip = false; ! // switch drawing screen ! if (usepageflip) { ! if (game_screen == game_screen1) ! game_screen = game_screen2; ! else ! game_screen = game_screen1; ! } else ! game_screen = game_screen1; ! //clear_to_color(game_screen, 0); double t = get_time2(); *************** *** 287,302 **** tempframe->prepare(); animate(tempframe); ! T->tree_setscreen(game_screen); // game_screen can change value... ! T->tree_animate(); show_mouse(game_screen); ! // when drawing is finished, do a page flip to the new screen. ! show_video_bitmap(game_screen); ! t = get_time2() - t;// - paused_time; render_history->add_element(pow(t, 4.0)); } --- 266,296 ---- tempframe->prepare(); + acquire_bitmap(tempframe->surface); animate(tempframe); + release_bitmap(tempframe->surface); ! acquire_bitmap(game_screen); ! if (T && !next) ! { ! T->tree_setscreen(game_screen); // game_screen can change value... ! T->tree_animate(); ! } ! release_bitmap(game_screen); show_mouse(game_screen); ! // when drawing is finished, you could do a page flip to the new screen. ! // but this can take as much as 8 ms, which is a long time ... cause it has to ! // wait for a vertical retrace sync of the monitor. So ... since the picture varies only ! // slightly in-between updates, and updating the video memory goes very fast (<2 ms), ! // page-flip isn't really needed... ! if (usepageflip) ! { ! show_video_bitmap(game_screen); // if you've to wait explicitly for a retrace ... ! } t = get_time2() - t;// - paused_time; + + render_history->add_element(pow(t, 4.0)); } Index: gameproject.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gameproject.h 14 Dec 2003 22:19:55 -0000 1.4 --- gameproject.h 15 Dec 2003 20:51:12 -0000 1.5 *************** *** 57,61 **** Frame2 *tempframe; TWindow *T; ! AreaTablet *maparea; // for game drawing WindowInfo wininfo; --- 57,61 ---- Frame2 *tempframe; TWindow *T; ! Area *maparea; // for game drawing WindowInfo wininfo; Index: gamesolarview.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamesolarview.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamesolarview.cpp 14 Dec 2003 14:20:58 -0000 1.2 --- gamesolarview.cpp 15 Dec 2003 20:51:12 -0000 1.3 *************** *** 27,31 **** T = new TWindow("gamex/interface/planetview", 0, 0, game_screen, true); ! maparea = new AreaTablet(T, "map_"); } --- 27,32 ---- T = new TWindow("gamex/interface/planetview", 0, 0, game_screen, true); ! maparea = new Area(T, "map_"); ! makevideobmp(maparea->backgr); // for faster drawing (I think ...) } *************** *** 253,260 **** return; ! FULL_REDRAW = 1; ! ::space_zoom = wininfo.zoomlevel; ! ::space_center = wininfo.mapcenter; --- 254,261 ---- return; ! // FULL_REDRAW = 1; ! // ::space_zoom = wininfo.zoomlevel; ! // ::space_center = wininfo.mapcenter; Index: gamestarmap.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamestarmap.cpp 14 Dec 2003 22:19:55 -0000 1.3 --- gamestarmap.cpp 15 Dec 2003 20:51:12 -0000 1.4 *************** *** 58,62 **** T = new TWindow("gamex/interface/starmap", 0, 0, game_screen, true); ! maparea = new AreaTablet(T, "map_"); } --- 58,62 ---- T = new TWindow("gamex/interface/starmap", 0, 0, game_screen, true); ! maparea = new Area(T, "map_"); } *************** *** 158,193 **** ! void GameStarmap::calculate() { - if (next) - return; - - ::space_view_size = wininfo.framesize; - ::space_zoom = wininfo.zoomlevel; - ::space_center = wininfo.mapcenter; - - ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); - - - GameBare::calculate(); - - if ( mouseper->update() && (mouse_b & 2) ) - { - if (view && view->frame && view->frame->window && view->frame->window->surface) - wininfo.centermove((mouse_x - maparea->pos.x - 0.5*view->frame->window->surface->w) / space_zoom, - (mouse_y - maparea->pos.y - 0.5*view->frame->window->surface->h) / space_zoom); - //wininfo.center(Vector2(0,0)); - } - - - double dt = frame_time * 1E-3; - - if (key[KEY_EQUALS]) - wininfo.zoom(1 + 1*dt); - - if (key[KEY_MINUS]) - wininfo.zoom(1 / (1 + 1*dt)); - - // keep track of the last star that was clicked on by the mouse if (ptr->selection && (ptr->selection->id == STAR_ID)) --- 158,163 ---- ! void GameStarmap::mapeditor_stuff() { // keep track of the last star that was clicked on by the mouse if (ptr->selection && (ptr->selection->id == STAR_ID)) *************** *** 313,316 **** --- 283,321 ---- } + } + + void GameStarmap::calculate() + { + if (next) + return; + + ::space_view_size = wininfo.framesize; + ::space_zoom = wininfo.zoomlevel; + ::space_center = wininfo.mapcenter; + + ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); + + + GameBare::calculate(); + + if ( mouseper->update() && (mouse_b & 2) ) + { + if (view && view->frame && view->frame->window && view->frame->window->surface) + wininfo.centermove((mouse_x - maparea->pos.x - 0.5*view->frame->window->surface->w) / space_zoom, + (mouse_y - maparea->pos.y - 0.5*view->frame->window->surface->h) / space_zoom); + //wininfo.center(Vector2(0,0)); + } + + + double dt = frame_time * 1E-3; + + if (key[KEY_EQUALS]) + wininfo.zoom(1 + 1*dt); + + if (key[KEY_MINUS]) + wininfo.zoom(1 / (1 + 1*dt)); + + + mapeditor_stuff(); } Index: gamestarmap.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamestarmap.h 14 Dec 2003 22:19:55 -0000 1.3 --- gamestarmap.h 15 Dec 2003 20:51:12 -0000 1.4 *************** *** 65,68 **** --- 65,69 ---- void update_bplot(); + void mapeditor_stuff(); }; Index: projectx.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/projectx.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** projectx.cpp 14 Dec 2003 14:20:58 -0000 1.4 --- projectx.cpp 15 Dec 2003 20:51:12 -0000 1.5 *************** *** 76,80 **** ! add( new GameStarmap() ); // add( new GamePlanetview() ); // add( new GamePlanetscan() ); --- 76,80 ---- ! // add( new GameStarmap() ); // add( new GamePlanetview() ); // add( new GamePlanetscan() ); |
From: <geo...@us...> - 2003-12-15 20:51:15
|
Update of /cvsroot/timewarp/source/twgui In directory sc8-pr-cvs1:/tmp/cvs-serv22001/twgui Modified Files: twbuttontypes.cpp twbuttontypes.h twwindow.cpp Log Message: fixed a mistake in the fg-game animate, and stuffed bitmaps in video-memory, which can be a big improvement... also, discarded use of page-flips cause that waits for a retrace (idle for 8 ms). Index: twbuttontypes.cpp =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twbuttontypes.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** twbuttontypes.cpp 12 Dec 2003 15:58:01 -0000 1.1 --- twbuttontypes.cpp 15 Dec 2003 20:51:12 -0000 1.2 *************** *** 76,79 **** --- 76,126 ---- + Area::Area(TWindow *menu, char *identbranch, int asciicode, bool akeepkey) + : + GraphicButton(menu, identbranch, asciicode, akeepkey) + { + init_pos_size(&backgr, "backgr"); + } + + + Area::~Area() + { + if (backgr) + destroy_bitmap(backgr); + } + + void Area::changebackgr(char *fname) + { + BITMAP *newb; + newb = getbmp(fname); + + if (newb) + { + destroy_bitmap(backgr); + backgr = newb; + } + } + + + void Area::animate() + { + draw(backgr); + } + + + bool Area::hasmouse() + { + // the first rough check whether it's in the boxed bitmap area + return GraphicButton::hasmouse(backgr); + } + + + bool Area::isvalid() + { + return backgr != 0; + }; + + + // an additional class, which has its own background and drawing area, which // can be used to create custom representations of information (eg., text or smaller *************** *** 85,92 **** AreaTablet::AreaTablet(TWindow *menu, char *identbranch, int asciicode, bool akeepkey) : ! GraphicButton(menu, identbranch, asciicode, akeepkey) { ! init_pos_size(&backgr, "backgr"); if (size.x != 0) --- 132,139 ---- AreaTablet::AreaTablet(TWindow *menu, char *identbranch, int asciicode, bool akeepkey) : ! Area(menu, identbranch, asciicode, akeepkey) { ! //init_pos_size(&backgr, "backgr"); if (size.x != 0) *************** *** 100,105 **** AreaTablet::~AreaTablet() { ! if (backgr) ! destroy_bitmap(backgr); if (drawarea) destroy_bitmap(drawarea); --- 147,152 ---- AreaTablet::~AreaTablet() { ! //if (backgr) ! // destroy_bitmap(backgr); if (drawarea) destroy_bitmap(drawarea); *************** *** 107,123 **** - void AreaTablet::changebackgr(char *fname) - { - BITMAP *newb; - newb = getbmp(fname); - - if (newb) - { - destroy_bitmap(backgr); - backgr = newb; - } - } - - void AreaTablet::animate() { --- 154,157 ---- *************** *** 127,130 **** --- 161,165 ---- draw(drawarea); + // draw(backgr); } Index: twbuttontypes.h =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twbuttontypes.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** twbuttontypes.h 14 Dec 2003 22:19:56 -0000 1.3 --- twbuttontypes.h 15 Dec 2003 20:51:12 -0000 1.4 *************** *** 30,45 **** // something which has a background, and its own drawing-area ! class AreaTablet : public GraphicButton { protected: public: ! BITMAP *backgr, *drawarea; AreaTablet(TWindow *menu, char *identbranch, int asciicode = 0, bool akeepkey = 0); virtual ~AreaTablet(); - - void changebackgr(char *fname); virtual void animate(); // shouldn't be changed. --- 30,63 ---- + class Area : public GraphicButton + { + protected: + + public: + BITMAP *backgr; + + Area(TWindow *menu, char *identbranch, int asciicode = 0, bool akeepkey = 0); + virtual ~Area(); + + virtual void changebackgr(char *fname); + + virtual void animate(); // shouldn't be changed. + + virtual bool hasmouse(); + virtual bool isvalid(); + }; + + + // something which has a background, and its own drawing-area ! class AreaTablet : public Area { protected: public: ! BITMAP *drawarea; AreaTablet(TWindow *menu, char *identbranch, int asciicode = 0, bool akeepkey = 0); virtual ~AreaTablet(); virtual void animate(); // shouldn't be changed. Index: twwindow.cpp =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twwindow.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** twwindow.cpp 14 Dec 2003 22:19:56 -0000 1.3 --- twwindow.cpp 15 Dec 2003 20:51:12 -0000 1.4 *************** *** 238,241 **** --- 238,243 ---- // the fist one should plot on top, and therefore, should be plotted last ... + acquire_bitmap(screen); + while (current) { *************** *** 243,246 **** --- 245,250 ---- current = current->prev; } + + release_bitmap(screen); } *************** *** 662,665 **** --- 666,672 ---- + // release for in-game drawing + acquire_bitmap(drawarea); + if (!disabled) { *************** *** 668,674 **** // also copy transparent color! ! // release for in-game drawing ! //release_bitmap(drawarea); ! blit(backgr, drawarea, 0, 0, 0, 0, W, H); --- 675,679 ---- // also copy transparent color! ! // this takes about 1 ms blit(backgr, drawarea, 0, 0, 0, 0, W, H); *************** *** 678,681 **** --- 683,688 ---- while (button) { + // "hyperspace" --> this takes 10 ms !! That's a lot for just that bitmap ... + // it's slow cause it goes from RAM to video-memory. button->animate(); button = button->next; *************** *** 687,693 **** if (screen) { ! //acquire_bitmap(screen); masked_blit(drawarea, screen, 0, 0, x, y, W, H); - //release_bitmap(screen); } --- 694,699 ---- if (screen) { ! // this takes about 2 ms. masked_blit(drawarea, screen, 0, 0, x, y, W, H); } *************** *** 696,699 **** --- 702,706 ---- masked_blit(drawarea, screen, 0, 0, x, y, W, H); + release_bitmap(drawarea); unscare_mouse(); |
From: <geo...@us...> - 2003-12-14 22:25:23
|
Update of /cvsroot/timewarp/gamex/interface/dialogeditor In directory sc8-pr-cvs1:/tmp/cvs-serv5032/dialogeditor Modified Files: backgr.bmp info.txt Log Message: no message Index: backgr.bmp =================================================================== RCS file: /cvsroot/timewarp/gamex/interface/dialogeditor/backgr.bmp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsNiqcnV and /tmp/cvs4RP1hV differ Index: info.txt =================================================================== RCS file: /cvsroot/timewarp/gamex/interface/dialogeditor/info.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** info.txt 12 Dec 2003 16:11:29 -0000 1.2 --- info.txt 14 Dec 2003 22:25:19 -0000 1.3 *************** *** 1,22 **** ! gamex/interface/dialogeditor/text/barver_backgr_y = 80 ! gamex/interface/dialogeditor/text/barver_backgr_x = 692 ! gamex/interface/dialogeditor/race_backgr_y = 10 ! gamex/interface/dialogeditor/race_backgr_x = 233 ! gamex/interface/dialogeditor/state_on_y = 8 ! gamex/interface/dialogeditor/state_on_x = 182 ! gamex/interface/dialogeditor/prevbranch_default_y = 421 ! gamex/interface/dialogeditor/prevbranch_default_x = 85 ! gamex/interface/dialogeditor/addbranch_default_y = 368 ! gamex/interface/dialogeditor/addbranch_default_x = 93 ! gamex/interface/dialogeditor/refresh_default_y = 160 ! gamex/interface/dialogeditor/refresh_default_x = 22 ! gamex/interface/dialogeditor/branches/down_default_y = 489 ! gamex/interface/dialogeditor/branches/down_default_x = 694 ! gamex/interface/dialogeditor/branches/up_default_y = 328 ! gamex/interface/dialogeditor/branches/up_default_x = 693 ! gamex/interface/dialogeditor/text/down_default_y = 256 ! gamex/interface/dialogeditor/text/down_default_x = 695 ! gamex/interface/dialogeditor/text/up_default_y = 58 ! gamex/interface/dialogeditor/text/up_default_x = 694 gamex/interface/dialogeditor/race/backgr_y = 10 gamex/interface/dialogeditor/race/backgr_x = 233 --- 1,22 ---- ! gamex/interface/dialogeditor/text/barver_backgr_y = 107 ! gamex/interface/dialogeditor/text/barver_backgr_x = 720 ! gamex/interface/dialogeditor/race_backgr_y = 37 ! gamex/interface/dialogeditor/race_backgr_x = 261 ! gamex/interface/dialogeditor/state_on_y = 35 ! gamex/interface/dialogeditor/state_on_x = 210 ! gamex/interface/dialogeditor/prevbranch_default_y = 448 ! gamex/interface/dialogeditor/prevbranch_default_x = 113 ! gamex/interface/dialogeditor/addbranch_default_y = 395 ! gamex/interface/dialogeditor/addbranch_default_x = 121 ! gamex/interface/dialogeditor/refresh_default_y = 187 ! gamex/interface/dialogeditor/refresh_default_x = 50 ! gamex/interface/dialogeditor/branches/down_default_y = 516 ! gamex/interface/dialogeditor/branches/down_default_x = 722 ! gamex/interface/dialogeditor/branches/up_default_y = 355 ! gamex/interface/dialogeditor/branches/up_default_x = 721 ! gamex/interface/dialogeditor/text/down_default_y = 283 ! gamex/interface/dialogeditor/text/down_default_x = 723 ! gamex/interface/dialogeditor/text/up_default_y = 85 ! gamex/interface/dialogeditor/text/up_default_x = 722 gamex/interface/dialogeditor/race/backgr_y = 10 gamex/interface/dialogeditor/race/backgr_x = 233 *************** *** 27,33 **** gamex/interface/dialogeditor/refresh/default_y = 160 gamex/interface/dialogeditor/refresh/default_x = 22 ! gamex/interface/dialogeditor/branches/backgr_y = 344 ! gamex/interface/dialogeditor/branches/backgr_x = 163 ! gamex/interface/dialogeditor/text/backgr_y = 70 ! gamex/interface/dialogeditor/text/backgr_x = 162 res = 800 --- 27,33 ---- gamex/interface/dialogeditor/refresh/default_y = 160 gamex/interface/dialogeditor/refresh/default_x = 22 ! gamex/interface/dialogeditor/branches/backgr_y = 371 ! gamex/interface/dialogeditor/branches/backgr_x = 191 ! gamex/interface/dialogeditor/text/backgr_y = 97 ! gamex/interface/dialogeditor/text/backgr_x = 190 res = 800 |
Update of /cvsroot/timewarp/gamex/interface/starmap/edit In directory sc8-pr-cvs1:/tmp/cvs-serv5032/starmap/edit Added Files: backgr.bmp dec_default.bmp inc_default.bmp info.txt new_default.bmp plot_default.bmp replace_default.bmp Log Message: no message --- NEW FILE: backgr.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: dec_default.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: inc_default.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: info.txt --- gamex/interface/starmap/edit/plot_default_y = 50 gamex/interface/starmap/edit/plot_default_x = 50 gamex/interface/starmap/edit/replace_default_y = 9 gamex/interface/starmap/edit/replace_default_x = 52 gamex/interface/starmap/edit/new_default_y = 160 gamex/interface/starmap/edit/new_default_x = 51 gamex/interface/starmap/edit/inc_default_y = 51 gamex/interface/starmap/edit/inc_default_x = 159 gamex/interface/starmap/edit/dec_default_y = 50 gamex/interface/starmap/edit/dec_default_x = 13 gamex/interface/planetview/edit/plot_default_y = 100 gamex/interface/planetview/edit/plot_default_x = 100 gamex/interface/planetview/edit/cancel_default_y = 17 gamex/interface/planetview/edit/cancel_default_x = 100 gamex/interface/planetview/edit/select_default_y = 318 gamex/interface/planetview/edit/select_default_x = 100 gamex/interface/planetview/edit/inc_default_y = 101 gamex/interface/planetview/edit/inc_default_x = 317 gamex/interface/planetview/edit/dec_default_y = 95 gamex/interface/planetview/edit/dec_default_x = 25 res = 1600 --- NEW FILE: new_default.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: plot_default.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: replace_default.bmp --- (This appears to be a binary file; contents omitted.) |
From: <geo...@us...> - 2003-12-14 22:23:16
|
Update of /cvsroot/timewarp/gamex/interface/starmap/edit In directory sc8-pr-cvs1:/tmp/cvs-serv4860/edit Log Message: Directory /cvsroot/timewarp/gamex/interface/starmap/edit added to the repository |
From: <geo...@us...> - 2003-12-14 22:19:59
|
Update of /cvsroot/timewarp/source/gamex In directory sc8-pr-cvs1:/tmp/cvs-serv3999/gamex Modified Files: gamedata.cpp gamedata.h gamedialogue.cpp gamedialogue.h gamegeneral.cpp gamegeneral.h gameproject.cpp gameproject.h gamestarmap.cpp gamestarmap.h Log Message: fg interface update/ starmap editor update Index: gamedata.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamedata.cpp 25 Nov 2003 00:13:08 -0000 1.2 --- gamedata.cpp 14 Dec 2003 22:19:55 -0000 1.3 *************** *** 279,282 **** --- 279,298 ---- + int MapSpacebody::rem(int k) + { + + if (k < 0 || k >= Nsub || Nsub == 0) + return 0; + + int i; + for ( i = k; i < Nsub-1; ++i ) + sub[i] = sub[i+1]; + --Nsub; + + return Nsub-1; + } + + + IndexTypeList::IndexTypeList(int omax, char *fname) { Index: gamedata.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedata.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gamedata.h 18 Nov 2003 17:18:47 -0000 1.1.1.1 --- gamedata.h 14 Dec 2003 22:19:55 -0000 1.2 *************** *** 81,84 **** --- 81,85 ---- virtual void save(FILE *f, int level); virtual int add(int level); + virtual int rem(int k); }; Index: gamedialogue.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedialogue.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamedialogue.cpp 12 Dec 2003 15:53:18 -0000 1.3 --- gamedialogue.cpp 14 Dec 2003 22:19:55 -0000 1.4 *************** *** 67,70 **** --- 67,78 ---- + + void GameAliendialog::init_menu() + { + T = new TWindow("gamex/interface/aliendialog", 10, 10, game_screen, true); + maparea = 0; + } + + void GameAliendialog::init() { *************** *** 77,80 **** --- 85,90 ---- prepare(); + ti = false; // no render/tic time info needed... + int i; *************** *** 110,114 **** FONT *usefont = videosystem.get_font(i); ! view->frame->prepare(); --- 120,124 ---- FONT *usefont = videosystem.get_font(i); ! // view->frame->prepare(); *************** *** 122,126 **** - R = new TWindow("gamex/interface/aliendialog", 10, 10, view->frame->surface); --- 132,135 ---- *************** *** 134,138 **** showline_Nlines = Nlines(dialo->T); //A = new TextEditBox(R, "A", -1, -1, usefont, showline(dialo.A, showline_num), 0); ! A = new TextInfoArea(R, "A/", usefont, 0, 0); // all text should fit on 1 window - no scroll needed !! //A->set_textcolor(tcol); --- 143,147 ---- showline_Nlines = Nlines(dialo->T); //A = new TextEditBox(R, "A", -1, -1, usefont, showline(dialo.A, showline_num), 0); ! A = new TextInfoArea(T, "A/", usefont, 0, 0); // all text should fit on 1 window - no scroll needed !! //A->set_textcolor(tcol); *************** *** 141,150 **** ! B = new TextList(R, "B/", usefont); //winman = new WindowManager; //winman->add(R); ! R->tree_doneinit(); initBlist(dialo); --- 150,159 ---- ! B = new TextList(T, "B/", usefont); //winman = new WindowManager; //winman->add(R); ! T->tree_doneinit(); initBlist(dialo); *************** *** 235,240 **** ! FULL_REDRAW = true; ! R->tree_calculate(); --- 244,249 ---- ! //FULL_REDRAW = true; ! //T->tree_calculate(); *************** *** 327,334 **** //show_mouse(frame->surface); ! R->tree_setscreen(view->frame->surface); ! R->tree_animate(); ! show_mouse(view->frame->surface); ! scare_mouse(); } --- 336,343 ---- //show_mouse(frame->surface); ! //R->tree_setscreen(view->frame->surface); ! //R->tree_animate(); ! //show_mouse(view->frame->surface); ! //scare_mouse(); } Index: gamedialogue.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamedialogue.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamedialogue.h 12 Dec 2003 15:53:18 -0000 1.2 --- gamedialogue.h 14 Dec 2003 22:19:55 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- virtual void init(); + virtual void init_menu(); virtual void quit(); //virtual bool handle_key(int k); *************** *** 31,35 **** ! TWindow *R; TextInfoArea *A; --- 32,36 ---- ! //TWindow *R; TextInfoArea *A; Index: gamegeneral.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamegeneral.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gamegeneral.cpp 12 Dec 2003 15:53:18 -0000 1.3 --- gamegeneral.cpp 14 Dec 2003 22:19:55 -0000 1.4 *************** *** 221,230 **** { int x, y; - int w, h; w = sprite->width(); h = sprite->height(); ! x = mouse_x - 0.5 * w; ! y = mouse_y - 0.5 * h; sprite->draw(x, y, 0, f->surface); --- 221,234 ---- { int x, y; int w, h; + w = sprite->width(); h = sprite->height(); ! ! Vector2 P; ! P = corner(pos); ! ! x = P.x - 0.5 * w; ! y = P.y - 0.5 * h; sprite->draw(x, y, 0, f->surface); *************** *** 257,261 **** --- 261,285 ---- } + void MousePtr::newpos(int x, int y) + { + pos.x = x; + pos.y = y; + + pos = uncorner(pos); + normalize(pos, map_size); + if (pos.x < 0) + pos.x = 0; + + if (pos.y < 0) + pos.y = 0; + + if (pos.x > map_size.x-1) + pos.x = map_size.x-1; + + if (pos.y > map_size.y-1) + pos.y = map_size.y-1; + + } void MousePtr::calculate() *************** *** 265,271 **** SpaceObject::calculate(); - pos.x = mouse_x; - pos.y = mouse_y; - // if the left mouse button is pressed, search for the closest object. // a null value means, there's no selection. --- 289,292 ---- *************** *** 277,284 **** double range2; ! Vector2 pos2; // note, the mouse pointer is "absolute" on the screen; ! pos2 = pos; ! pos = uncorner(pos); range2 = mouserange / space_zoom; --- 298,305 ---- double range2; ! // Vector2 pos2; // note, the mouse pointer is "absolute" on the screen; ! // pos2 = pos; ! // pos = uncorner(pos); range2 = mouserange / space_zoom; *************** *** 302,306 **** } ! pos = pos2; } --- 323,327 ---- } ! // pos = pos2; } Index: gamegeneral.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamegeneral.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** gamegeneral.h 18 Nov 2003 17:18:48 -0000 1.1.1.1 --- gamegeneral.h 14 Dec 2003 22:19:55 -0000 1.2 *************** *** 17,20 **** --- 17,22 ---- virtual void animate(Frame *f); virtual void calculate(); + + void newpos(int x, int y); }; Index: gameproject.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gameproject.cpp 14 Dec 2003 14:20:58 -0000 1.3 --- gameproject.cpp 14 Dec 2003 22:19:55 -0000 1.4 *************** *** 14,18 **** ! BITMAP *game_screen; --- 14,18 ---- ! BITMAP *game_screen, *game_screen1, *game_screen2; *************** *** 162,166 **** init_menu(); ! if (!T || !maparea) { tw_error("Game menu is not defined !!"); --- 162,166 ---- init_menu(); ! if (!T) { tw_error("Game menu is not defined !!"); *************** *** 168,178 **** // use this for game-drawing to part of the menu ! tempframe->setsurface(maparea->backgr); ! wininfo.init( Vector2(800,800), 800.0, tempframe ); // performance check tic_history = new Histograph(128); render_history = new Histograph(128); } --- 168,182 ---- // use this for game-drawing to part of the menu ! if (maparea) ! { ! tempframe->setsurface(maparea->backgr); ! wininfo.init( Vector2(800,800), 800.0, tempframe ); ! } // performance check tic_history = new Histograph(128); render_history = new Histograph(128); + ti = true; } *************** *** 226,230 **** // (and the game frame then draws to video memory?) ! show_ticinfo(frame, tic_history, render_history, 4.0); --- 230,235 ---- // (and the game frame then draws to video memory?) ! if (ti) ! show_ticinfo(frame, tic_history, render_history, 4.0); *************** *** 238,241 **** --- 243,253 ---- return; + // switch drawing screen + if (game_screen == game_screen1) + game_screen = game_screen2; + else + game_screen = game_screen1; + //clear_to_color(game_screen, 0); + /* *************** *** 277,284 **** --- 289,301 ---- animate(tempframe); + T->tree_setscreen(game_screen); // game_screen can change value... T->tree_animate(); show_mouse(game_screen); + // when drawing is finished, do a page flip to the new screen. + show_video_bitmap(game_screen); + + t = get_time2() - t;// - paused_time; render_history->add_element(pow(t, 4.0)); *************** *** 385,393 **** // first, allocate the (old) screen from memory ... this should match // exactly the "global" screen ... ! game_screen = create_video_bitmap(screen->w, screen->h); ! if (!game_screen) { tw_error("Failed to initialize game_screen!"); } show_video_bitmap(game_screen); clear_to_color(game_screen, 0); --- 402,412 ---- // first, allocate the (old) screen from memory ... this should match // exactly the "global" screen ... ! game_screen1 = create_video_bitmap(screen->w, screen->h); ! game_screen2 = create_video_bitmap(screen->w, screen->h); ! if (!(game_screen1 && game_screen2)) { tw_error("Failed to initialize game_screen!"); } + game_screen = game_screen1; show_video_bitmap(game_screen); clear_to_color(game_screen, 0); *************** *** 401,407 **** void GameProject::quit() { ! if (game_screen) ! destroy_bitmap(game_screen); ! show_video_bitmap(screen); // result of an empty project: nothing to do, also on exiting it } --- 420,432 ---- void GameProject::quit() { ! if (game_screen1) ! show_video_bitmap(game_screen1); ! ! if (game_screen1) ! destroy_bitmap(game_screen1); ! ! if (game_screen2) ! destroy_bitmap(game_screen2); ! // result of an empty project: nothing to do, also on exiting it } Index: gameproject.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gameproject.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gameproject.h 14 Dec 2003 14:20:58 -0000 1.3 --- gameproject.h 14 Dec 2003 22:19:55 -0000 1.4 *************** *** 126,129 **** --- 126,130 ---- // performance check + bool ti; Histograph *tic_history; Histograph *render_history; Index: gamestarmap.cpp =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamestarmap.cpp 14 Dec 2003 14:20:58 -0000 1.2 --- gamestarmap.cpp 14 Dec 2003 22:19:55 -0000 1.3 *************** *** 17,20 **** --- 17,22 ---- #include "gamestarmap.h" + #include "../twgui/twpopup.h" + *************** *** 123,134 **** lastselectionstar = 0; maphaschanged = false; // check if the map changed; if so, it's to be written back to disk - } void GameStarmap::calculate() { GameBare::calculate(); --- 125,173 ---- lastselectionstar = 0; maphaschanged = false; // check if the map changed; if so, it's to be written back to disk + // define another (sub)menu + + Tedit = new Popup("gamex/interface/starmap/edit", 400, 200, game_screen); + Tedit->exclusive = true; + + + bdec = new Button(Tedit, "dec_"); + binc = new Button(Tedit, "inc_"); + bnew = new Button(Tedit, "new_"); + breplace = new Button(Tedit, "replace_"); + bplot = new Button(Tedit, "plot_"); + + istarselect = 0; + update_bplot(); + + T->add(Tedit); + T->tree_doneinit(); + } + + + void GameStarmap::update_bplot() + { + BITMAP *dest, *src; + src = starspr[istarselect]->get_bitmap(0); + dest = bplot->bmp_default; + clear_to_color(dest, 0); + blit(src, dest, 0, 0, 0, 0, src->w, src->h); + } void GameStarmap::calculate() { + if (next) + return; + + ::space_view_size = wininfo.framesize; + ::space_zoom = wininfo.zoomlevel; + ::space_center = wininfo.mapcenter; + + ptr->newpos(mouse_x - maparea->pos.x, mouse_y - maparea->pos.y); + + GameBare::calculate(); *************** *** 136,141 **** { if (view && view->frame && view->frame->window && view->frame->window->surface) ! wininfo.centermove((mouse_x - 0.5*view->frame->window->surface->w) / space_zoom, ! (mouse_y - 0.5*view->frame->window->surface->h) / space_zoom); //wininfo.center(Vector2(0,0)); } --- 175,180 ---- { if (view && view->frame && view->frame->window && view->frame->window->surface) ! wininfo.centermove((mouse_x - maparea->pos.x - 0.5*view->frame->window->surface->w) / space_zoom, ! (mouse_y - maparea->pos.y - 0.5*view->frame->window->surface->h) / space_zoom); //wininfo.center(Vector2(0,0)); } *************** *** 159,209 **** ! // select a star for movement (or so ...) ! if ( (!selectionstar) && key[KEY_LCONTROL] && lastselectionstar) { ! selectionstar = lastselectionstar; } ! // add a new star (or toggle its type if it's still selected) ! if (keyper->update()) { ! if (key[KEY_A]) ! { ! if (!selectionstar) ! { ! selectionstar = new Star(0, 0, 0, starspr[0]); ! add(selectionstar); ! ! // also ... add it to the map ?? with default settings .. ! selectionstar->starnum = starmap->add(1); // level 1 = stars ! ! } else { ! int k; ! k = selectionstar->starnum; ! int &startype = starmap->sub[k]->type; ! ++ startype; ! if (startype > startypelist->N - 1) ! startype = 0; - selectionstar->set_sprite(starspr[startype]); - } - } - } ! // move a star ! if (selectionstar) ! { ! selectionstar->pos = wininfo.mapcenter + ! Vector2( (mouse_x - 0.5*view->frame->window->surface->w) / space_zoom, ! (mouse_y - 0.5*view->frame->window->surface->h) / space_zoom ); ! staywithin(0, &(selectionstar->pos), map_size); } // place a star ! if ( selectionstar && (mouse_b & 1) ) { // update the map with this star ? --- 198,229 ---- ! // move a star ! if (selectionstar) { ! ! selectionstar->pos = ptr->pos; ! staywithin(0, &(selectionstar->pos), map_size); } ! // delete a star ! if (selectionstar && keyhandler.keyhit[KEY_DEL]) { ! // remove from game physics ! remove(selectionstar); ! // remove from the map ! starmap->rem(selectionstar->starnum); ! // remove from memory ! delete selectionstar; ! selectionstar = 0; } // place a star ! if ( selectionstar && maparea->flag.left_mouse_press )//(mouse_b & 1) ) { // update the map with this star ? *************** *** 218,224 **** --- 238,319 ---- maphaschanged = true; + + maparea->flag.left_mouse_press = false; // cause you've used it now + } + + + // select a star for movement (or so ...) + //if ( (!selectionstar) && key[KEY_LCONTROL] && lastselectionstar) + // using left-click of the mouse on the starmap area of the menu + if ( (!selectionstar) && lastselectionstar && maparea->flag.left_mouse_press ) + { + selectionstar = lastselectionstar; + + maparea->flag.left_mouse_press = false; + } + + + + // --------------- + + // by pressing "space", you initialize the menu + if (keyhandler.keyhit[KEY_SPACE]) + { + Tedit->show(); + Tedit->center_abs(mouse_x, mouse_y); + } + + if (breplace->flag.left_mouse_press) + { + Tedit->hide(); + T->show(); + + // change the picture of the selected star + if (selectionstar) + { + int k; + k = selectionstar->starnum; + starmap->sub[k]->type = istarselect; + selectionstar->set_sprite(starspr[istarselect]); + } + } + + if (bnew->flag.left_mouse_press) + { + Tedit->hide(); + T->show(); + + // select this picture for a new star ? + if (!selectionstar) + { + selectionstar = new Star(0, 0, 0, starspr[istarselect]); + add(selectionstar); + + // also ... add it to the map ?? with default settings .. + selectionstar->starnum = starmap->add(1); // level 1 = stars + + } + } + + if (binc->flag.left_mouse_press || bdec->flag.left_mouse_press) + { + if (binc->flag.left_mouse_press) + ++istarselect; + + if (bdec->flag.left_mouse_press) + --istarselect; + + if (istarselect < 0 ) + istarselect = startypelist->N - 1; + + if (istarselect >= startypelist->N) + istarselect = 0; + + update_bplot(); + } } + void GameStarmap::animate(Frame *frame) Index: gamestarmap.h =================================================================== RCS file: /cvsroot/timewarp/source/gamex/gamestarmap.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gamestarmap.h 14 Dec 2003 14:20:58 -0000 1.2 --- gamestarmap.h 14 Dec 2003 22:19:55 -0000 1.3 *************** *** 29,32 **** --- 29,37 ---- public: + TWindow *Tedit; + // contents of Tedit + Button *bdec, *binc, *bnew, *breplace, *bplot; + int istarselect; + double scalepos; Star *selectionstar, *lastselectionstar; *************** *** 58,61 **** --- 63,68 ---- SpaceSprite *starspr[32], *playerspr; bool maphaschanged; + + void update_bplot(); }; |
From: <geo...@us...> - 2003-12-14 22:19:59
|
Update of /cvsroot/timewarp/source/twgui In directory sc8-pr-cvs1:/tmp/cvs-serv3999/twgui Modified Files: twbuttontypes.h twwindow.cpp twwindow.h Log Message: fg interface update/ starmap editor update Index: twbuttontypes.h =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twbuttontypes.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** twbuttontypes.h 13 Dec 2003 14:31:56 -0000 1.2 --- twbuttontypes.h 14 Dec 2003 22:19:56 -0000 1.3 *************** *** 13,19 **** { protected: - BITMAP *bmp_default, *bmp_focus, *bmp_selected; public: Button(TWindow *menu, char *identbranch, int asciicode = 0, bool keepkey = 0); virtual ~Button(); --- 13,20 ---- { protected: public: + BITMAP *bmp_default, *bmp_focus, *bmp_selected; + Button(TWindow *menu, char *identbranch, int asciicode = 0, bool keepkey = 0); virtual ~Button(); *************** *** 59,64 **** { protected: - BITMAP *bmp_on, *bmp_off; public: bool state; // true=on, false=off // x, y, W, H are inside the draw area --- 60,66 ---- { protected: public: + BITMAP *bmp_on, *bmp_off; + bool state; // true=on, false=off // x, y, W, H are inside the draw area *************** *** 93,98 **** { protected: - BITMAP *button; public: enum {hor = 1, ver= 2} direction ; --- 95,100 ---- { protected: public: + BITMAP *button; enum {hor = 1, ver= 2} direction ; Index: twwindow.cpp =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twwindow.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** twwindow.cpp 13 Dec 2003 14:31:56 -0000 1.2 --- twwindow.cpp 14 Dec 2003 22:19:56 -0000 1.3 *************** *** 388,391 **** --- 388,406 ---- + + + void TWindow::center_abs(int xcenter, int ycenter) + { + // put back the background + //blit(originalscreen, screen, 0, 0, x, y, W, H); + + // move + x = xcenter - W / 2; + y = ycenter - H / 2; + + // read the new background + //blit(screen, originalscreen, x, y, 0, 0, W, H); + } + void TWindow::center() { Index: twwindow.h =================================================================== RCS file: /cvsroot/timewarp/source/twgui/twwindow.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** twwindow.h 13 Dec 2003 14:31:56 -0000 1.2 --- twwindow.h 14 Dec 2003 22:19:56 -0000 1.3 *************** *** 120,123 **** --- 120,124 ---- // this centers the bitmap on this position. + void center_abs(int xcenter, int ycenter); void center(int xcenter, int ycenter); void center(); |