Selaa lähdekoodia

Menu play button working

Thomas Buck 10 vuotta sitten
vanhempi
commit
ac8022ec70
8 muutettua tiedostoa jossa 32 lisäystä ja 40 poistoa
  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 Näytä tiedosto

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

+ 2
- 0
include/Menu.h Näytä tiedosto

44
 
44
 
45
     void displayMapList();
45
     void displayMapList();
46
 
46
 
47
+    void play();
48
+
47
     bool mVisible;
49
     bool mVisible;
48
     unsigned int mCursor;
50
     unsigned int mCursor;
49
     unsigned int mMin;
51
     unsigned int mMin;

+ 1
- 7
include/Render.h Näytä tiedosto

53
         fAllRooms               = (1 << 14)
53
         fAllRooms               = (1 << 14)
54
     } RenderFlags;
54
     } RenderFlags;
55
 
55
 
56
-    typedef enum {
57
-        roomMesh,
58
-        skeletalMesh
59
-    } RenderMeshType;
60
-
61
     /*!
56
     /*!
62
      * \brief Constructs an object of Render
57
      * \brief Constructs an object of Render
63
      */
58
      */
166
      *
161
      *
167
      * Texture must be initialized.
162
      * Texture must be initialized.
168
      * \param r_mesh Mesh to render.
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
     //! \fixme should be private
167
     //! \fixme should be private
174
 
168
 

+ 0
- 2
include/Room.h Näytä tiedosto

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

+ 0
- 2
include/RoomData.h Näytä tiedosto

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

+ 12
- 8
src/Menu.cpp Näytä tiedosto

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
 void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
207
 void Menu::handleKeyboard(KeyboardButton key, bool pressed) {
198
     if (!pressed)
208
     if (!pressed)
199
         return;
209
         return;
221
         while (i-- > 0)
231
         while (i-- > 0)
222
             handleKeyboard(upKey, true);
232
             handleKeyboard(upKey, true);
223
     } else if (key == enterKey) {
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
         mCursor = mMin + (y / 25);
246
         mCursor = mMin + (y / 25);
243
     } else if ((y >= 25) && (y <= 100) && (x >= 25) && (x <= 125)) {
247
     } else if ((y >= 25) && (y <= 100) && (x >= 25) && (x <= 125)) {
244
         // Play button
248
         // Play button
245
-        mCursor = 0;
249
+        play();
246
     }
250
     }
247
 }
251
 }
248
 
252
 

+ 7
- 20
src/Render.cpp Näytä tiedosto

900
 
900
 
901
                 if (tag2)
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
                     {
943
                     {
944
                         glPushMatrix();
944
                         glPushMatrix();
945
                         glTranslatef(mdl->ponyOff2, 0.0, 0.0);
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
                         glPopMatrix();
947
                         glPopMatrix();
949
 
948
 
950
                         glPushMatrix();
949
                         glPushMatrix();
951
                         glTranslatef(-mdl->ponyOff2, 0.0, 0.0);
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
                         glPopMatrix();
952
                         glPopMatrix();
955
                     }
953
                     }
956
                     else
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
             }
966
             }
970
         }
967
         }
971
 
968
 
972
-        drawModelMesh(getWorld().getMesh(tag->mesh), Render::skeletalMesh);
969
+        drawModelMesh(getWorld().getMesh(tag->mesh));
973
     }
970
     }
974
 
971
 
975
     // Cycle frames ( cheap hack from old ent state based system )
972
     // Cycle frames ( cheap hack from old ent state based system )
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
     texture_tri_t *ttri;
1215
     texture_tri_t *ttri;
1219
     int lastTexture = -1;
1216
     int lastTexture = -1;
1230
     glColor3fv(WHITE);
1227
     glColor3fv(WHITE);
1231
 
1228
 
1232
     if (mMode == modeWireframe)
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
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1232
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1246
     glBindTexture(GL_TEXTURE_2D, 1);  // White texture for colors
1233
     glBindTexture(GL_TEXTURE_2D, 1);  // White texture for colors

+ 9
- 1
src/RoomData.cpp Näytä tiedosto

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

Loading…
Peruuta
Tallenna