]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Menu.cpp
Changed namespace Menu for a class
[lugaru.git] / Source / Menu.cpp
index c402c8d39f50ad9374730629579672e05e5a5d5b..49b47321239a0ba2dcc4f53c5ded0626d844c248 100644 (file)
@@ -1,54 +1,32 @@
-#include <vector>
-#include <string>
-#include "gamegl.h"
-
-#include "Menu.h"
-using namespace Menu;
+/*
+Copyright (C) 2003, 2010 - Wolfire Games
+Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
 
-extern float multiplier;
+This file is part of Lugaru.
 
-struct MenuItem {
-    enum MenuItemType {NONE, LABEL, BUTTON, IMAGE, IMAGEBUTTON, MAPMARKER, MAPLINE, MAPLABEL} type;
-    int id;
-    string text;
-    Texture texture;
-    int x, y, w, h;
-    float r, g, b;
-    float effectfade;
+Lugaru 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.
 
-    float linestartsize;
-    float lineendsize;
+Lugaru 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.
 
-    void init(MenuItemType _type, int _id, const string& _text, Texture _texture,
-              int _x, int _y, int _w, int _h, float _r, float _g, float _b,
-              float _linestartsize = 1, float _lineendsize = 1) {
-        type = _type;
-        id = _id;
-        text = _text;
-        texture = _texture;
-        x = _x;
-        y = _y;
-        w = _w;
-        h = _h;
-        r = _r;
-        g = _g;
-        b = _b;
-        effectfade = 0;
-        linestartsize = _linestartsize;
-        lineendsize = _lineendsize;
-        if (type == MenuItem::BUTTON) {
-            if (w == -1)
-                w = text.length() * 10;
-            if (h == -1)
-                h = 20;
-        }
-    }
-};
+You should have received a copy of the GNU General Public License
+along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
+*/
 
-vector<MenuItem> items;
+#include <vector>
+#include <string>
+#include "gamegl.h"
 
+#include "Menu.h"
 
+extern float multiplier;
 
+std::vector<MenuItem> Menu::items;
 
 void Menu::clearMenu()
 {
@@ -132,7 +110,7 @@ int Menu::getSelected(int mousex, int mousey)
     return -1;
 }
 
-void GUITick()
+void Menu::handleFadeEffect()
 {
     for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
         if (it->id == Game::selected) {
@@ -149,7 +127,7 @@ void GUITick()
 
 void Menu::drawItems()
 {
-    GUITick();
+    handleFadeEffect();
     glEnable(GL_TEXTURE_2D);
     glEnable(GL_ALPHA_TEST);
     glEnable(GL_BLEND);
@@ -251,6 +229,9 @@ void Menu::drawItems()
             glEnable(GL_TEXTURE_2D);
         }
         break;
+        default:
+        case MenuItem::NONE:
+        break;
         }
     }
 }