Bläddra i källkod

Menu play button working

Thomas Buck 10 år sedan
förälder
incheckning
ac8022ec70
8 ändrade filer med 32 tillägg och 40 borttagningar
  1. 1
    0
      ChangeLog.md
  2. 2
    0
      include/Menu.h
  3. 1
    7
      include/Render.h
  4. 0
    2
      include/Room.h
  5. 0
    2
      include/RoomData.h
  6. 12
    8
      src/Menu.cpp
  7. 7
    20
      src/Render.cpp
  8. 9
    1
      src/RoomData.cpp

+ 1
- 0
ChangeLog.md Visa fil

@@ -5,6 +5,7 @@
5 5
     [ 20140505 ]
6 6
     * Moved setup of Room, Portal, Box, Sector, ... into their
7 7
       Constructors.
8
+    * Fixed menu play button
8 9
 
9 10
     [ 20140504 ]
10 11
     * Forcing use of new Room and Sprite classes in World.

+ 2
- 0
include/Menu.h Visa fil

@@ -44,6 +44,8 @@ private:
44 44
 
45 45
     void displayMapList();
46 46
 
47
+    void play();
48
+
47 49
     bool mVisible;
48 50
     unsigned int mCursor;
49 51
     unsigned int mMin;

+ 1
- 7
include/Render.h Visa fil

@@ -53,11 +53,6 @@ public:
53 53
         fAllRooms               = (1 << 14)
54 54
     } RenderFlags;
55 55
 
56
-    typedef enum {
57
-        roomMesh,
58
-        skeletalMesh
59
-    } RenderMeshType;
60
-
61 56
     /*!
62 57
      * \brief Constructs an object of Render
63 58
      */
@@ -166,9 +161,8 @@ public:
166 161
      *
167 162
      * Texture must be initialized.
168 163
      * \param r_mesh Mesh to render.
169
-     * \param type Must be object containing mesh
170 164
      */
171
-    void drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type);
165
+    void drawModelMesh(model_mesh_t *r_mesh);
172 166
 
173 167
     //! \fixme should be private
174 168
 

+ 0
- 2
include/Room.h Visa fil

@@ -9,9 +9,7 @@
9 9
 #define _ROOM_H_
10 10
 
11 11
 #include <vector>
12
-#include <memory>
13 12
 #include "math/math.h"
14
-#include "math/Matrix.h"
15 13
 #include "Mesh.h"
16 14
 #include "Sprite.h"
17 15
 #include "TombRaider.h"

+ 0
- 2
include/RoomData.h Visa fil

@@ -12,8 +12,6 @@
12 12
 #include <memory>
13 13
 #include "math/math.h"
14 14
 #include "math/Matrix.h"
15
-#include "Mesh.h"
16
-#include "Sprite.h"
17 15
 #include "TombRaider.h"
18 16
 
19 17
 class Light {

+ 12
- 8
src/Menu.cpp Visa fil

@@ -194,6 +194,16 @@ void Menu::display() {
194 194
     }
195 195
 }
196 196
 
197
+void Menu::play() {
198
+    char *tmp = bufferString("load %s", mMapList[mCursor]);
199
+    if (getOpenRaider().command(tmp) == 0) {
200
+        setVisible(false);
201
+    } else {
202
+        //! \todo Display something if an error occurs
203
+    }
204
+    delete [] tmp;
205
+}
206
+
197 207
 void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
198 208
     if (!pressed)
199 209
         return;
@@ -221,13 +231,7 @@ void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
221 231
         while (i-- > 0)
222 232
             handleKeyboard(upKey, true);
223 233
     } else if (key == enterKey) {
224
-        char *tmp = bufferString("load %s", mMapList[mCursor]);
225
-        if (getOpenRaider().command(tmp) == 0) {
226
-            setVisible(false);
227
-        } else {
228
-            //! \todo Display something if an error occurs
229
-        }
230
-        delete [] tmp;
234
+        play();
231 235
     }
232 236
 }
233 237
 
@@ -242,7 +246,7 @@ void Menu::handleMouseClick(unsigned int x, unsigned int y, KeyboardButton butto
242 246
         mCursor = mMin + (y / 25);
243 247
     } else if ((y >= 25) && (y <= 100) && (x >= 25) && (x <= 125)) {
244 248
         // Play button
245
-        mCursor = 0;
249
+        play();
246 250
     }
247 251
 }
248 252
 

+ 7
- 20
src/Render.cpp Visa fil

@@ -900,7 +900,7 @@ void Render::drawModel(SkeletalModel *model)
900 900
 
901 901
                 if (tag2)
902 902
                 {
903
-                    drawModelMesh(getWorld().getMesh(tag2->mesh), Render::skeletalMesh);
903
+                    drawModelMesh(getWorld().getMesh(tag2->mesh));
904 904
                 }
905 905
             }
906 906
         }
@@ -943,20 +943,17 @@ void Render::drawModel(SkeletalModel *model)
943 943
                     {
944 944
                         glPushMatrix();
945 945
                         glTranslatef(mdl->ponyOff2, 0.0, 0.0);
946
-                        drawModelMesh(getWorld().getMesh(mdl->ponytailMeshId + i),
947
-                                Render::skeletalMesh);
946
+                        drawModelMesh(getWorld().getMesh(mdl->ponytailMeshId + i));
948 947
                         glPopMatrix();
949 948
 
950 949
                         glPushMatrix();
951 950
                         glTranslatef(-mdl->ponyOff2, 0.0, 0.0);
952
-                        drawModelMesh(getWorld().getMesh(mdl->ponytailMeshId + i),
953
-                                Render::skeletalMesh);
951
+                        drawModelMesh(getWorld().getMesh(mdl->ponytailMeshId + i));
954 952
                         glPopMatrix();
955 953
                     }
956 954
                     else
957 955
                     {
958
-                        drawModelMesh(getWorld().getMesh(mdl->ponytailMeshId + i),
959
-                                Render::skeletalMesh);
956
+                        drawModelMesh(getWorld().getMesh(mdl->ponytailMeshId + i));
960 957
                     }
961 958
                 }
962 959
 
@@ -969,7 +966,7 @@ void Render::drawModel(SkeletalModel *model)
969 966
             }
970 967
         }
971 968
 
972
-        drawModelMesh(getWorld().getMesh(tag->mesh), Render::skeletalMesh);
969
+        drawModelMesh(getWorld().getMesh(tag->mesh));
973 970
     }
974 971
 
975 972
     // Cycle frames ( cheap hack from old ent state based system )
@@ -1213,7 +1210,7 @@ void Render::tmpRenderModelMesh(model_mesh_t *r_mesh, texture_tri_t *ttri)
1213 1210
 }
1214 1211
 
1215 1212
 
1216
-void Render::drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type)
1213
+void Render::drawModelMesh(model_mesh_t *r_mesh)
1217 1214
 {
1218 1215
     texture_tri_t *ttri;
1219 1216
     int lastTexture = -1;
@@ -1230,17 +1227,7 @@ void Render::drawModelMesh(model_mesh_t *r_mesh, RenderMeshType type)
1230 1227
     glColor3fv(WHITE);
1231 1228
 
1232 1229
     if (mMode == modeWireframe)
1233
-    {
1234
-        switch (type)
1235
-        {
1236
-            case roomMesh:
1237
-                glColor3fv(YELLOW);
1238
-                break;
1239
-            case skeletalMesh:
1240
-                glColor3fv(WHITE);
1241
-                break;
1242
-        }
1243
-    }
1230
+        glColor3fv(WHITE);
1244 1231
 
1245 1232
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1246 1233
     glBindTexture(GL_TEXTURE_2D, 1);  // White texture for colors

+ 9
- 1
src/RoomData.cpp Visa fil

@@ -69,6 +69,8 @@ Light::LightType Light::getType() {
69 69
     return type;
70 70
 }
71 71
 
72
+// ----------------------------------------------------------------------------
73
+
72 74
 StaticModel::StaticModel(TombRaider &tr, unsigned int room, unsigned int i) {
73 75
     tr.getRoomModel(room, i, &index, pos, &yaw);
74 76
 }
@@ -86,7 +88,7 @@ void StaticModel::display() {
86 88
     glTranslated(pos[0], pos[1], pos[2]);
87 89
     glRotated(yaw, 0, 1, 0);
88 90
 
89
-    getRender().drawModelMesh(mesh, Render::roomMesh);
91
+    getRender().drawModelMesh(mesh);
90 92
     glPopMatrix();
91 93
 }
92 94
 
@@ -99,6 +101,8 @@ bool StaticModel::operator<(const StaticModel &other) {
99 101
     return (distA < distB);
100 102
 }
101 103
 
104
+// ----------------------------------------------------------------------------
105
+
102 106
 Portal::Portal(TombRaider &tr, unsigned int room, unsigned int index, Matrix &transform) {
103 107
     float portalVertices[12];
104 108
     tr.getRoomPortal(room, index, &adjoiningRoom, normal, portalVertices);
@@ -124,10 +128,14 @@ int Portal::getAdjoiningRoom() {
124 128
     return adjoiningRoom;
125 129
 }
126 130
 
131
+// ----------------------------------------------------------------------------
132
+
127 133
 Box::Box(TombRaider &tr, unsigned int room, unsigned int index) {
128 134
     tr.getRoomBox(room, index, a, b, c, d);
129 135
 }
130 136
 
137
+// ----------------------------------------------------------------------------
138
+
131 139
 Sector::Sector(TombRaider &tr, unsigned int room, unsigned int index) {
132 140
     unsigned int sectorFlags;
133 141
     int floorDataIndex, boxIndex, roomBelow, roomAbove;

Laddar…
Avbryt
Spara