Page MenuHomePhabricator (Chris)

Title_Menu.cpp
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

Title_Menu.cpp

/****************************************************************************
** Copyright (C) 2011 Luka Horvat <redreaper132 at gmail.com>
** Copyright (C) 2011 Edward Lii <edward_iii at myway.com>
** Copyright (C) 2011 O. Bahri Gordebak <gordebak at gmail.com>
**
**
** This file may be used under the terms of the GNU General Public
** License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**
****************************************************************************/
#include "Functions.h"
#include "Classes.h"
#include "Globals.h"
#include "Title_Menu.h"
static int m_nHighlight=0;
Menu::Menu()
{
s_menu = load_image(DATA_PATH "data/gfx/menu/menu.png");
m_nHighlight=0;
}
Menu::~Menu()
{
}
void Menu::handle_events()
{
int x, y;
SDL_GetMouseState(&x, &y);
m_nHighlight=0;
if(x>=200&&x<600&&y>=150&&y<550){
m_nHighlight=(y-50)/100;
}
if ( event.type == SDL_MOUSEBUTTONUP && event.button.button == SDL_BUTTON_LEFT )
{
switch(m_nHighlight){
case 1:
next_state(STATE_LEVEL_SELECT);
break;
case 2:
next_state(STATE_HELP);
break;
case 3:
m_sLevelName="./leveledit.map";
next_state(STATE_LEVEL_EDITOR);
break;
case 4:
next_state(STATE_EXIT);
break;
}
}
if ( event.type == SDL_QUIT )
{
next_state(STATE_EXIT);
}
if ( event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_s )
{
if ( Mix_PlayingMusic() == 1 )
{
Mix_HaltMusic();
}
else
{
Mix_PlayMusic(music,-1);
}
}
}
void Menu::logic()
{
}
void Menu::render()
{
apply_surface( 0,0,s_menu,screen,NULL );
if(m_nHighlight>0){
SDL_Rect r,r1;
r.x=200;
r.y=50+100*m_nHighlight;
r.w=400;
r.h=1;
SDL_FillRect(screen,&r,0);
r1.x=200;
r1.y=r.y;
r1.w=1;
r1.h=100;
SDL_FillRect(screen,&r1,0);
r1.x=600;
SDL_FillRect(screen,&r1,0);
r.y+=100;
SDL_FillRect(screen,&r,0);
}
}
Help::Help()
{
s_help = load_image(DATA_PATH "data/gfx/menu/help.png");
}
Help::~Help()
{
}
void Help::handle_events()
{
if ( event.type == SDL_KEYUP || event.type == SDL_MOUSEBUTTONUP )
{
next_state(STATE_MENU);
}
if ( event.type == SDL_QUIT )
{
next_state(STATE_EXIT);
}
/*if ( event.type == SDL_KEYUP && event.key.keysym.sym == SDLK_ESCAPE )
{
next_state(STATE_MENU);
}*/
}
void Help::logic()
{
}
void Help::render()
{
apply_surface( 0, 0, s_help, screen, NULL);
}

File Metadata

Mime Type
text/x-c
Expires
Sat, Nov 14, 8:55 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
132521
Default Alt Text
Title_Menu.cpp (2 KB)

Event Timeline