[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Feuerkraft-CVS] rev 319 - in trunk: data src src/input
From: |
Ingo Ruhnke |
Subject: |
[Feuerkraft-CVS] rev 319 - in trunk: data src src/input |
Date: |
Tue, 09 Dec 2003 23:52:19 +0100 |
Author: grumbel
Date: 2003-12-09 23:52:19 +0100 (Tue, 09 Dec 2003)
New Revision: 319
Modified:
trunk/data/feuerkraft.scm
trunk/src/game_session.cxx
trunk/src/game_session.hxx
trunk/src/input/controller.cxx
trunk/src/input/controller.hxx
trunk/src/input/input_event.hxx
trunk/src/input/input_manager_custom.cxx
trunk/src/soldier.cxx
Log:
- made menu and join-vehicle usable again, wouldn't really call it a fix
Modified: trunk/data/feuerkraft.scm
===================================================================
--- trunk/data/feuerkraft.scm 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/data/feuerkraft.scm 2003-12-09 22:52:19 UTC (rev 319)
@@ -142,12 +142,6 @@
(player-set-current-unit (player-get-soldier))
(gameobj-set-property (player-get-soldier) "hidden" #f))))))
-(input-register-callback "key_k" join-nearest-vehicle)
-(input-register-callback "joy_3" join-nearest-vehicle)
-
-(input-register-callback "key_f1" display-show-help)
-(input-register-callback "key_f2" display-hide-help)
-
(define (toggle-levelmap)
(if (display-levelmap-visible)
(display-hide-levelmap)
@@ -158,15 +152,7 @@
(if (menu-visible)
(menu-hide)
(menu-show 0)))
-
-(input-register-callback "key_m" toggle-levelmap)
-(input-register-callback "joy_2" toggle-menu)
-(input-register-callback "key_a" toggle-menu)
-
-(input-register-callback "key_escape" game-quit)
-(input-register-callback "key_p" game-pause)
-
(define (bomber-attack x-pos y-pos)
(trigger-add-timed
3
@@ -316,17 +302,8 @@
(menu-add-item comm-menu "Mount Vehicle" join-nearest-vehicle)
-;;(menu-add-item comm-menu "Back >>>" menu-hide)
-
;; End: Interface definition
-(input-register-callback "mouse_right"
- (lambda ()
- (let ((x (input-get-mouse-world-x))
- (y (input-get-mouse-world-y)))
- (format #t "### Keyboard pressed: mouse: ~A ~A
~%" x y)
- )))
-
(define (random-ref vec)
(vector-ref vec (random (vector-length vec))))
@@ -369,6 +346,23 @@
;; Make an endless list
(list-cdr-set! editor-insert-funcs (1- (length editor-insert-funcs))
editor-insert-funcs)
+;; Core events
+(input-register-callback "key_k" join-nearest-vehicle)
+
+;; Support events, also reachable via menu
+(input-register-callback "mouse_right"
+ (lambda ()
+ (let ((x (input-get-mouse-world-x))
+ (y (input-get-mouse-world-y)))
+ (format #t "### Keyboard pressed: mouse: ~A ~A
~%" x y)
+ )))
+
+(input-register-callback "key_f1" display-show-help)
+(input-register-callback "key_f2" display-hide-help)
+(input-register-callback "key_m" toggle-levelmap)
+(input-register-callback "key_escape" game-quit)
+(input-register-callback "key_p" game-pause)
+
(input-register-callback "mouse_left"
(lambda ()
(let ((x (input-get-mouse-world-x))
Modified: trunk/src/game_session.cxx
===================================================================
--- trunk/src/game_session.cxx 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/src/game_session.cxx 2003-12-09 22:52:19 UTC (rev 319)
@@ -44,6 +44,7 @@
#include "display_manager.hxx"
#include "buildings/building_type_manager.hxx"
#include "scripting/clanlib_commands.hxx"
+#include "scripting/menu_commands.hxx"
#include "collision_manager.hxx"
#include "sexpr_world_reader.hxx"
#include "guile.hxx"
@@ -63,7 +64,8 @@
extern CommandLineArguments* args;
GameSession::GameSession(const std::string& arg_filename)
- : filename(arg_filename),
+ : control_state(UNIT_CONTROL),
+ filename(arg_filename),
do_quit(false),
do_pause(false)
{
@@ -238,16 +240,52 @@
clanlib_call_post_keep_alive_func();
InputManager::update(delta);
- // FIXME: Add an input dispatcher here, depending on the
- // dispatcher state, input should go to the menu, to the
- // comm-dialog or to the players vehicle
- if (DisplayManager::current()->get_menu())
+ InputEventLst lst = InputManager::get_controller().get_events();
+ for(InputEventLst::iterator i = lst.begin(); i != lst.end(); ++i)
{
-
DisplayManager::current()->get_menu()->process_events(InputManager::get_events());
+ if (i->type == BUTTON_EVENT)
+ {
+ if (i->button.name == MENU_BUTTON && i->button.is_down())
+ {
+ if (control_state == MENU_CONTROL)
+ {
+ menu_hide();
+ control_state = UNIT_CONTROL;
+ }
+ else
+ {
+ menu_show(0);
+ control_state = MENU_CONTROL;
+ }
+ }
+ else if (i->button.name == USE_BUTTON && i->button.is_down())
+ {
+ // FIXME: Unclean hack
+ gh_call0(gh_lookup("join-nearest-vehicle"));
+ }
+ }
}
- else
+
+ switch (control_state)
{
+ case MENU_CONTROL:
+ if (DisplayManager::current()->get_menu())
+
DisplayManager::current()->get_menu()->process_events(InputManager::get_events());
+ else
+ {
+ std::cout << "Error: Menu not available, fallback to unit" <<
std::endl;
+ control_state = UNIT_CONTROL;
+ }
+ break;
+
+ case UNIT_CONTROL:
player->get_current_unit()->update_controlls(InputManager::get_controller());
+ break;
+
+ default:
+ std::cout << "Unknown ControlState, switching back to UNIT_CONTROL" <<
std::endl;
+ control_state = UNIT_CONTROL;
+ break;
}
InputManager::clear();
Modified: trunk/src/game_session.hxx
===================================================================
--- trunk/src/game_session.hxx 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/src/game_session.hxx 2003-12-09 22:52:19 UTC (rev 319)
@@ -31,6 +31,8 @@
class GameSession
{
private:
+ enum ControlState { UNIT_CONTROL, MENU_CONTROL } control_state;
+
std::string filename;
bool do_quit;
bool do_pause;
@@ -42,9 +44,9 @@
BuildingTypeManager* buildingtypemanager;
CollisionManager* collision_mgr;
GameWorld* world;
- View* view;
+ View* view;
+
public:
-
GameSession(const std::string& arg_filename);
void init();
Modified: trunk/src/input/controller.cxx
===================================================================
--- trunk/src/input/controller.cxx 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/src/input/controller.cxx 2003-12-09 22:52:19 UTC (rev 319)
@@ -26,7 +26,10 @@
accelerate_axis = 0.0f;
strafe_axis = 0.0f;
- primary_fire_button = false;
+ primary_fire_button = false;
+ secondary_fire_button = false;
+ use_button = false;
+ menu_button = false;
}
float
@@ -40,6 +43,7 @@
return accelerate_axis;
case STRAFE_AXIS:
return strafe_axis;
+
default:
AssertMsg(0, "Controllor: Unknown AxisName");
return 0;
@@ -55,6 +59,7 @@
return primary_fire_button;
case SECONDARY_FIRE_BUTTON:
return secondary_fire_button;
+
default:
AssertMsg(0, "Controller: Unknown ButtonName");
return false;
@@ -92,7 +97,11 @@
secondary_fire_button = down;
break;
case USE_BUTTON:
+ use_button = down;
break;
+ case MENU_BUTTON:
+ menu_button = down;
+ break;
default:
AssertMsg(0, "Controller: Unknown ButtonName");
}
Modified: trunk/src/input/controller.hxx
===================================================================
--- trunk/src/input/controller.hxx 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/src/input/controller.hxx 2003-12-09 22:52:19 UTC (rev 319)
@@ -34,6 +34,8 @@
bool primary_fire_button;
bool secondary_fire_button;
+ bool use_button;
+ bool menu_button;
InputEventLst events;
Modified: trunk/src/input/input_event.hxx
===================================================================
--- trunk/src/input/input_event.hxx 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/src/input/input_event.hxx 2003-12-09 22:52:19 UTC (rev 319)
@@ -24,7 +24,7 @@
enum InputEventType { BUTTON_EVENT, AXIS_EVENT };
enum AxisName { ORIENTATION_AXIS, ACCELERATE_AXIS, STRAFE_AXIS };
-enum ButtonName { PRIMARY_FIRE_BUTTON, SECONDARY_FIRE_BUTTON, USE_BUTTON };
+enum ButtonName { PRIMARY_FIRE_BUTTON, SECONDARY_FIRE_BUTTON, USE_BUTTON,
MENU_BUTTON };
struct ButtonEvent
{
Modified: trunk/src/input/input_manager_custom.cxx
===================================================================
--- trunk/src/input/input_manager_custom.cxx 2003-12-09 21:36:20 UTC (rev
318)
+++ trunk/src/input/input_manager_custom.cxx 2003-12-09 22:52:19 UTC (rev
319)
@@ -38,10 +38,12 @@
slots.push_back(primary_button->on_key_down().connect (this,
&InputManagerCustom::on_button_down, PRIMARY_FIRE_BUTTON));
slots.push_back(secondary_button->on_key_down().connect(this,
&InputManagerCustom::on_button_down, SECONDARY_FIRE_BUTTON));
slots.push_back(use_button->on_key_down().connect (this,
&InputManagerCustom::on_button_down, USE_BUTTON));
+ slots.push_back(menu_button->on_key_down().connect (this,
&InputManagerCustom::on_button_down, MENU_BUTTON));
slots.push_back(primary_button->on_key_up().connect (this,
&InputManagerCustom::on_button_up, PRIMARY_FIRE_BUTTON));
slots.push_back(secondary_button->on_key_up().connect(this,
&InputManagerCustom::on_button_up, SECONDARY_FIRE_BUTTON));
slots.push_back(use_button->on_key_up().connect (this,
&InputManagerCustom::on_button_up, USE_BUTTON));
+ slots.push_back(menu_button->on_key_up().connect (this,
&InputManagerCustom::on_button_up, MENU_BUTTON));
slots.push_back(orientation_axis->on_move().connect(this,
&InputManagerCustom::on_axis_move, ORIENTATION_AXIS));
slots.push_back(accelerate_axis->on_move().connect(this,
&InputManagerCustom::on_axis_move, ACCELERATE_AXIS));
Modified: trunk/src/soldier.cxx
===================================================================
--- trunk/src/soldier.cxx 2003-12-09 21:36:20 UTC (rev 318)
+++ trunk/src/soldier.cxx 2003-12-09 22:52:19 UTC (rev 319)
@@ -30,7 +30,7 @@
Soldier::Soldier(const AList& lst)
: ai(0),
- sur (resources->get_sprite("feuerkraft/soldier"))
+ sur(resources->get_sprite("feuerkraft/soldier"))
{
pos.x = lst.get_float("x-pos");
pos.y = lst.get_float("y-pos");
@@ -69,7 +69,7 @@
}
void
-Soldier::update (float delta)
+Soldier::update(float delta)
{
sur.update(delta);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Feuerkraft-CVS] rev 319 - in trunk: data src src/input,
Ingo Ruhnke <=