[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Feuerkraft-CVS] rev 300 - in trunk: data/missions src src/scripting src
From: |
Ingo Ruhnke |
Subject: |
[Feuerkraft-CVS] rev 300 - in trunk: data/missions src src/scripting src/vehicles |
Date: |
Sat, 06 Dec 2003 02:16:00 +0100 |
Author: grumbel
Date: 2003-12-06 02:16:00 +0100 (Sat, 06 Dec 2003)
New Revision: 300
Added:
trunk/src/communication_dialog.cxx
trunk/src/communication_dialog.hxx
trunk/src/vehicles/rotor_description.hxx
Modified:
trunk/data/missions/airport.scm
trunk/src/Makefile.am
trunk/src/alist.cxx
trunk/src/alist.hxx
trunk/src/display_manager.cxx
trunk/src/game_session.cxx
trunk/src/scripting/comm_commands.cxx
trunk/src/scripting/comm_commands.hxx
trunk/src/vehicles/helicopter.cxx
trunk/src/vehicles/rotor.hxx
Log:
- added better rotor support
- added unit communication dialogs
Modified: trunk/data/missions/airport.scm
===================================================================
--- trunk/data/missions/airport.scm 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/data/missions/airport.scm 2003-12-06 01:16:00 UTC (rev 300)
@@ -325,4 +325,8 @@
(airport:add-waypoints *waypoints*)
+(input-register-callback "key_4"
+ (lambda ()
+ (comm-unit-message 82 "Heavy damage taken\nNeed
help emidiatly!")))
+
;; EOF ;;
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/Makefile.am 2003-12-06 01:16:00 UTC (rev 300)
@@ -30,6 +30,8 @@
command_line_arguments.cxx \
color.hxx \
color.cxx \
+communication_dialog.hxx \
+communication_dialog.cxx \
collision_manager.hxx \
collision_manager.cxx \
display_manager.hxx \
Modified: trunk/src/alist.cxx
===================================================================
--- trunk/src/alist.cxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/alist.cxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -246,6 +246,21 @@
}
}
+bool
+AList::retrieve_float_vector2d (const std::string& name, FloatVector2d& value)
const
+{
+ return false;
+ /*
+ const Value* v = get_value(name, AL_FLOATVECTOR2D);
+ if (!v)
+ return false;
+ else
+ {
+ value = v->v_float_vector2d;
+ return true;
+ }*/
+}
+
int
AList::get_int(const std::string& str, int def) const
{
Modified: trunk/src/alist.hxx
===================================================================
--- trunk/src/alist.hxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/alist.hxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -43,6 +43,7 @@
bool v_bool;
std::string* v_string;
IntVector2d v_int_vector2d;
+ FloatVector2d* v_float_vector2d;
};
};
private:
@@ -79,6 +80,7 @@
std::string get_string(const std::string& str, const std::string& ref =
std::string()) const;
bool retrieve_int_vector2d (const std::string& str, IntVector2d& value)
const;
+ bool retrieve_float_vector2d (const std::string& str, FloatVector2d& value)
const;
/** Merg lst into the current list, overwriting all values in *this
that are also in lst */
Added: trunk/src/communication_dialog.cxx
===================================================================
--- trunk/src/communication_dialog.cxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/communication_dialog.cxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -0,0 +1,86 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <ClanLib/Display/display.h>
+#include "fonts.hxx"
+#include "unit.hxx"
+#include "view.hxx"
+#include "game_obj_manager.hxx"
+#include "communication_dialog.hxx"
+
+CommunicationDialog* CommunicationDialog::current_ = 0;
+
+CommunicationDialog::CommunicationDialog()
+{
+ current_ = this;
+
+}
+
+CommunicationDialog::~CommunicationDialog()
+{
+}
+
+void
+CommunicationDialog::draw (CL_GraphicContext& gc)
+{
+ for(Messages::iterator i = messages.begin(); i != messages.end(); ++i)
+ {
+ Unit* unit =
dynamic_cast<Unit*>(GameObjManager::current()->get_object_by_id(i->first));
+ if (unit)
+ {
+ CL_Font font = Fonts::font;
+ CL_Rect bbox = font.bounding_rect(0, 0, i->second);
+
+ FloatVector2d unit_pos =
View::current()->world_to_screen(unit->get_pos());
+ FloatVector2d dialog_pos = unit_pos + FloatVector2d(0, -
50-bbox.get_height());
+
+ CL_Display::draw_line((int)unit_pos.x, (int)unit_pos.y-40,
+ (int)dialog_pos.x, (int)dialog_pos.y+20,
+ CL_Color(0,0,0, 100));
+
+ CL_Display::draw_line((int)unit_pos.x, (int)unit_pos.y-40,
+ (int)dialog_pos.x-20, (int)dialog_pos.y+20,
+ CL_Color(0,0,0, 100));
+
+ CL_Display::fill_rect(CL_Rect(CL_Point(int(dialog_pos.x -
bbox.get_width()/2),
+ int(dialog_pos.y -
bbox.get_height())),
+ CL_Size(bbox.get_width() + 20,
+ bbox.get_height() + 20)),
+ //CL_Color(85,85,0, 230));
+ CL_Color(0,0,0, 100));
+
+ font.set_alignment(origin_bottom_center);
+ font.draw(int(dialog_pos.x+10), int(dialog_pos.y+10), i->second);
+ }
+ }
+}
+
+void
+CommunicationDialog::send(int unit_id, const std::string& message)
+{
+ messages[unit_id] = message;
+}
+
+void
+CommunicationDialog::update (float delta)
+{
+
+}
+
+/* EOF */
Added: trunk/src/communication_dialog.hxx
===================================================================
--- trunk/src/communication_dialog.hxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/communication_dialog.hxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -0,0 +1,51 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_COMMUNICATION_DIALOG_HXX
+#define HEADER_COMMUNICATION_DIALOG_HXX
+
+#include <map>
+#include "gui_obj.hxx"
+
+/** */
+class CommunicationDialog : public GuiObj
+{
+private:
+ typedef std::map<int, std::string> Messages;
+ Messages messages;
+
+ static CommunicationDialog* current_;
+public:
+ static CommunicationDialog* current() { return current_; }
+
+ CommunicationDialog();
+ ~CommunicationDialog();
+
+ void send(int id, const std::string& message);
+
+ void draw (CL_GraphicContext& gc);
+ void update (float delta);
+private:
+ CommunicationDialog (const CommunicationDialog&);
+ CommunicationDialog& operator= (const CommunicationDialog&);
+};
+
+#endif
+
+/* EOF */
Modified: trunk/src/display_manager.cxx
===================================================================
--- trunk/src/display_manager.cxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/display_manager.cxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -25,6 +25,7 @@
#include "level_map.hxx"
#include "vehicle_status.hxx"
#include "message_buffer.hxx"
+#include "communication_dialog.hxx"
#include "display_manager.hxx"
extern Player* player;
@@ -50,6 +51,7 @@
screen.add(message_buffer = new MessageBuffer(CL_Display::get_width()/2,
CL_Display::get_height() - 30));
help = new Help();
screen.add(radar = new Radar(FloatVector2d(64, 64), player));
+ screen.add(new CommunicationDialog());
screen.add(vehicle_status = new VehicleStatus());
}
Modified: trunk/src/game_session.cxx
===================================================================
--- trunk/src/game_session.cxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/game_session.cxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -126,7 +126,16 @@
world->add(new RobotTank(660, 1245, 0, 100.0f));
world->add(new Helicopter(AList()
.set_float("x-pos", 600)
- .set_float("y-pos", 1245)));
+ .set_float("y-pos", 1245)
+ .set_int("type", 0)));
+ world->add(new Helicopter(AList()
+ .set_float("x-pos", 600)
+ .set_float("y-pos", 1445)
+ .set_int("type", 1)));
+ world->add(new Helicopter(AList()
+ .set_float("x-pos", 660)
+ .set_float("y-pos", 1645)
+ .set_int("type", 2)));
world->add(new Tank(FloatVector2d (650, 1245), 5, "feuerkraft/tank",
"feuerkraft/turret", "feuerkraft/fire2"));
world->add(new Tank(FloatVector2d (750, 1245), 5, "feuerkraft/tank",
"feuerkraft/turret", "feuerkraft/fire2"));
@@ -226,6 +235,7 @@
// someone closes the window.
CL_System::keep_alive();
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
@@ -237,6 +247,7 @@
{
player->get_current_unit()->update_controlls(InputManager::get_controller());
}
+
InputManager::clear();
}
Modified: trunk/src/scripting/comm_commands.cxx
===================================================================
--- trunk/src/scripting/comm_commands.cxx 2003-12-05 21:57:38 UTC (rev
299)
+++ trunk/src/scripting/comm_commands.cxx 2003-12-06 01:16:00 UTC (rev
300)
@@ -20,6 +20,7 @@
#include <iostream>
#include <sstream>
#include "../message_buffer.hxx"
+#include "../communication_dialog.hxx"
#include "comm_commands.hxx"
void
@@ -31,4 +32,10 @@
MessageBuffer::current()->add(s.str());
}
+void
+comm_unit_message(int unit, const char* str)
+{
+ CommunicationDialog::current()->send(unit, str);
+}
+
/* EOF */
Modified: trunk/src/scripting/comm_commands.hxx
===================================================================
--- trunk/src/scripting/comm_commands.hxx 2003-12-05 21:57:38 UTC (rev
299)
+++ trunk/src/scripting/comm_commands.hxx 2003-12-06 01:16:00 UTC (rev
300)
@@ -25,6 +25,8 @@
void comm_send_message(int color, const char* str);
+void comm_unit_message(int unit, const char* str);
+
//@}
#endif
Modified: trunk/src/vehicles/helicopter.cxx
===================================================================
--- trunk/src/vehicles/helicopter.cxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/vehicles/helicopter.cxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -27,34 +27,57 @@
#include "helicopter.hxx"
Helicopter::Helicopter(const AList& lst)
- :
- //rotor("feuerkraft/huey_rotor",
- // "feuerkraft/huey_rotor2"),
- //heli (resources->get_sprite ("feuerkraft/chuey")),
- //heli_shadow (resources->get_sprite ("feuerkraft/huey_shadow")),
- heli (resources->get_sprite ("feuerkraft/chinook")),
- heli_shadow (resources->get_sprite ("feuerkraft/chinook_shadow")),
- helidestroyed (resources->get_sprite ("feuerkraft/helidestroyed")),
- strafe (0.0),
- fireing (false),
- reloading (0),
- energie (100),
- destroyed (false),
- ai(0)
+ : strafe (0.0),
+ fireing (false),
+ reloading (0),
+ energie (100),
+ destroyed (false),
+ ai(0)
{
- RotorDescription rotor1;
- rotor1.offset = FloatVector2d(40.0f, 0);
- rotor1.slow_sprite = "feuerkraft/chinook_rotor";
- rotor1.fast_sprite = "feuerkraft/chinook_rotor2";
- rotor1.direction = RotorDescription::LEFT;
- rotors.push_back(Rotor(rotor1));
+ if (lst.get_int("type") == 0)
+ {
+ heli = resources->get_sprite("feuerkraft/huey");
+ heli_shadow = resources->get_sprite("feuerkraft/huey_shadow");
+ helidestroyed = resources->get_sprite("feuerkraft/helidestroyed");
+
+ RotorDescription rotor;
+ rotor.direction = RotorDescription::LEFT;
+ rotor.slow_sprite ="feuerkraft/huey_rotor";
+ rotor.fast_sprite = "feuerkraft/huey_rotor2";
+ rotors.push_back(Rotor(rotor));
+ }
+ else if (lst.get_int("type") == 1)
+ {
+ heli = resources->get_sprite("feuerkraft/helicopter");
+ heli_shadow = resources->get_sprite("feuerkraft/helicopter_shadow");
+ helidestroyed = resources->get_sprite("feuerkraft/helidestroyed");
+
+ RotorDescription rotor;
+ rotor.direction = RotorDescription::LEFT;
+ rotor.slow_sprite ="feuerkraft/huey_rotor";
+ rotor.fast_sprite = "feuerkraft/huey_rotor2";
+ rotors.push_back(Rotor(rotor));
+ }
+ else // if (lst.get_int("type") == 2)
+ {
+ heli = resources->get_sprite("feuerkraft/chinook");
+ heli_shadow = resources->get_sprite("feuerkraft/chinook_shadow");
+ helidestroyed = resources->get_sprite("feuerkraft/helidestroyed");
+
+ RotorDescription rotor1;
+ rotor1.offset = FloatVector2d(40.0f, 0);
+ rotor1.slow_sprite = "feuerkraft/chinook_rotor";
+ rotor1.fast_sprite = "feuerkraft/chinook_rotor2";
+ rotor1.direction = RotorDescription::LEFT;
+ rotors.push_back(Rotor(rotor1));
- RotorDescription rotor2;
- rotor2.offset = FloatVector2d(-40.0f, 0);
- rotor2.slow_sprite = "feuerkraft/chinook_rotor";
- rotor2.fast_sprite = "feuerkraft/chinook_rotor2";
- rotor2.direction = RotorDescription::RIGHT;
- rotors.push_back(Rotor(rotor2));
+ RotorDescription rotor2;
+ rotor2.offset = FloatVector2d(-40.0f, 0);
+ rotor2.slow_sprite = "feuerkraft/chinook_rotor";
+ rotor2.fast_sprite = "feuerkraft/chinook_rotor2";
+ rotor2.direction = RotorDescription::RIGHT;
+ rotors.push_back(Rotor(rotor2));
+ }
pos.x = lst.get_float("x-pos");
pos.y = lst.get_float("y-pos");
Modified: trunk/src/vehicles/rotor.hxx
===================================================================
--- trunk/src/vehicles/rotor.hxx 2003-12-05 21:57:38 UTC (rev 299)
+++ trunk/src/vehicles/rotor.hxx 2003-12-06 01:16:00 UTC (rev 300)
@@ -21,20 +21,10 @@
#define HEADER_FEUERKRAFT_VEHICLES_ROTOR_HXX
#include <ClanLib/Display/sprite.h>
+#include "rotor_description.hxx"
class View;
-class RotorDescription
-{
-public:
- enum Direction { LEFT, RIGHT };
-
- std::string slow_sprite;
- std::string fast_sprite;
- FloatVector2d offset;
- RotorDescription::Direction direction;
-};
-
/** */
class Rotor
{
Added: trunk/src/vehicles/rotor_description.hxx
===================================================================
--- trunk/src/vehicles/rotor_description.hxx 2003-12-05 21:57:38 UTC (rev
299)
+++ trunk/src/vehicles/rotor_description.hxx 2003-12-06 01:16:00 UTC (rev
300)
@@ -0,0 +1,37 @@
+// $Id$
+//
+// Pingus - A free Lemmings clone
+// Copyright (C) 2002 Ingo Ruhnke <address@hidden>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_ROTOR_DESCRIPTION_HXX
+#define HEADER_ROTOR_DESCRIPTION_HXX
+
+
+class RotorDescription
+{
+public:
+ enum Direction { LEFT, RIGHT };
+
+ std::string slow_sprite;
+ std::string fast_sprite;
+ FloatVector2d offset;
+ RotorDescription::Direction direction;
+};
+
+#endif
+
+/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Feuerkraft-CVS] rev 300 - in trunk: data/missions src src/scripting src/vehicles,
Ingo Ruhnke <=