Skip to content

Commit

Permalink
Disabled some more code, game now starts up and plays music, no graph…
Browse files Browse the repository at this point in the history
…ics yet, just a black screen
  • Loading branch information
Grumbel committed Jul 30, 2014
1 parent a5e96e2 commit 0b1e736
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 78 deletions.
4 changes: 4 additions & 0 deletions src/gui/button_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ ButtonGroup::event(SDL_Event &event)

if(mouse_left_button)
{
#ifdef OLD_SDL1
pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/g_screen->w);
pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/g_screen->h);
caught_event = true;
#endif
}
if(event.button.x > pos.x-12 && event.button.x < pos.x+16 + buttons_box.x*buttons_size.x &&
event.button.y > pos.y-4 && event.button.y < pos.y+8 + buttons_box.y*buttons_size.y)
Expand All @@ -119,6 +121,7 @@ ButtonGroup::event(SDL_Event &event)

caught_event = true;

#ifdef OLD_SDL1
if(event.button.button == SDL_MOUSEBUTTONUP)
{
row--;
Expand All @@ -137,6 +140,7 @@ ButtonGroup::event(SDL_Event &event)
mouse_left_button = true;
else
caught_event = false;
#endif
break;
case SDL_MOUSEBUTTONUP:
mouse_left_button = false;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ Menu::event(const SDL_Event& event)
case SDL_MOUSEBUTTONDOWN:
if(event.button.button == SDL_BUTTON_LEFT)
{
#ifdef OLD_SDL1
int x = int(event.motion.x * float(SCREEN_WIDTH)/g_screen->w);
int y = int(event.motion.y * float(SCREEN_HEIGHT)/g_screen->h);

Expand All @@ -780,11 +781,13 @@ Menu::event(const SDL_Event& event)
{
menuaction = MENU_ACTION_HIT;
}
#endif
}
break;

case SDL_MOUSEMOTION:
{
#ifdef OLD_SDL1
float x = event.motion.x * SCREEN_WIDTH/g_screen->w;
float y = event.motion.y * SCREEN_HEIGHT/g_screen->h;

Expand All @@ -810,6 +813,7 @@ Menu::event(const SDL_Event& event)
if(MouseCursor::current())
MouseCursor::current()->set_state(MC_NORMAL);
}
#endif
}
break;

Expand Down
2 changes: 2 additions & 0 deletions src/gui/mousecursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void MouseCursor::set_mid(int x, int y)

void MouseCursor::draw(DrawingContext& context)
{
#ifdef OLD_SDL1
if(cur_state == MC_HIDE)
return;

Expand All @@ -80,6 +81,7 @@ void MouseCursor::draw(DrawingContext& context)

context.draw_surface_part(cursor, Vector(0, h*cur_state),
Vector(w, h), Vector(x-mid_x, y-mid_y), LAYER_GUI+100);
#endif
}

/* EOF */
4 changes: 1 addition & 3 deletions src/scripting/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,7 @@ void camera()
log_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl;
}

SDL_Window *screen;

void set_gamma(float gamma) {
void set_gamma(float /*gamma*/) {
#ifdef OLD_SDL1
SDL_SetWindowGammaRamp(screen,gamma, gamma, gamma);
#endif
Expand Down
1 change: 0 additions & 1 deletion src/supertux/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "supertux/globals.hpp"
#include <tinygettext/tinygettext.hpp>

SDL_Surface* g_screen;
JoystickKeyboardController* g_jk_controller = 0;
tinygettext::DictionaryManager* dictionary_manager = 0;

Expand Down
2 changes: 0 additions & 2 deletions src/supertux/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ extern int SCREEN_HEIGHT;
// global variables
extern JoystickKeyboardController* g_jk_controller;

extern SDL_Surface* g_screen;

extern ScreenManager* g_screen_manager;

extern TextureManager* texture_manager;
Expand Down
5 changes: 2 additions & 3 deletions src/supertux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,9 @@ Main::init_video()
SCREEN_WIDTH = 800;
SCREEN_HEIGHT = 600;

/* SDL_Window *window; // Declare a pointer to an SDL_Window
context_pointer->init_renderer();
g_screen = SDL_GetWindowSurface(*window);*/

#ifdef OLD_SDL1
// SDL_WM_SetCaption(PACKAGE_NAME " " PACKAGE_VERSION, 0);

/* // set icon -- Original part B4 SDL2
Expand Down Expand Up @@ -531,7 +530,7 @@ Main::init_video()
640, 480,
SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
// not sure of that */

#endif
SDL_ShowCursor(0);

log_info << (g_config->use_fullscreen?"fullscreen ":"window ")
Expand Down
2 changes: 2 additions & 0 deletions src/supertux/menu/options_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ OptionsMenu::OptionsMenu() :

for(int disp_mode_ctr = 0; disp_mode_ctr < SDL_GetNumDisplayModes(0); disp_mode_ctr++)
{
#ifdef OLD_SDL1
SDL_DisplayMode* current = NULL;
int disp_retval = SDL_GetDisplayMode(0, // Display Index
disp_mode_ctr, // Mode index (default to first)
Expand All @@ -127,6 +128,7 @@ OptionsMenu::OptionsMenu() :
else
{
}
#endif
}
// On Ubuntu/Linux resolutions are returned from highest to
// lowest, so reverse them
Expand Down
11 changes: 8 additions & 3 deletions src/video/sdl/sdl_lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "video/sdl/sdl_texture.hpp"

SDLLightmap::SDLLightmap() :
screen(),
red_channel(),
blue_channel(),
green_channel(),
Expand All @@ -31,8 +30,6 @@ SDLLightmap::SDLLightmap() :
denominator(),
LIGHTMAP_DIV()
{
screen = SDL_GetWindowSurface(SDL_GetMouseFocus());

//float xfactor = 1.0f; // FIXME: (float) config->screenwidth / SCREEN_WIDTH;
//float yfactor = 1.0f; // FIXME: (float) config->screenheight / SCREEN_HEIGHT;

Expand All @@ -52,6 +49,7 @@ SDLLightmap::SDLLightmap() :
}
*/

#ifdef OLD_SDL1
LIGHTMAP_DIV = 8 * numerator / denominator;

width = screen->w / LIGHTMAP_DIV;
Expand All @@ -60,6 +58,7 @@ SDLLightmap::SDLLightmap() :
red_channel = (Uint8 *)malloc(width * height * sizeof(Uint8));
green_channel = (Uint8 *)malloc(width * height * sizeof(Uint8));
blue_channel = (Uint8 *)malloc(width * height * sizeof(Uint8));
#endif
}

SDLLightmap::~SDLLightmap()
Expand Down Expand Up @@ -100,6 +99,7 @@ void merge(Uint8 color[3], Uint8 color0[3], Uint8 color1[3], int rem, int total)
void
SDLLightmap::do_draw()
{
#ifdef OLD_SDL1
// FIXME: This is really slow
if(LIGHTMAP_DIV == 1)
{
Expand Down Expand Up @@ -290,6 +290,7 @@ SDLLightmap::do_draw()
SDL_UnlockSurface(screen);
}
}
#endif
}

void
Expand Down Expand Up @@ -444,6 +445,7 @@ SDLLightmap::light_blit(SDL_Surface *src, SDL_Rect *src_rect, int dstx, int dsty
void
SDLLightmap::draw_surface(const DrawingRequest& request)
{
#ifdef OLD_SDL1
if((request.color.red == 0.0 && request.color.green == 0.0 && request.color.blue == 0.0) || request.color.alpha == 0.0 || request.alpha == 0.0)
{
return;
Expand All @@ -469,11 +471,13 @@ SDLLightmap::draw_surface(const DrawingRequest& request)
int dstx = (int) request.pos.x * numerator / denominator;
int dsty = (int) request.pos.y * numerator / denominator;
light_blit(transform, src_rect, dstx, dsty);
#endif
}

void
SDLLightmap::draw_surface_part(const DrawingRequest& request)
{
#ifdef OLD_SDL1
const SurfacePartRequest* surfacepartrequest
= (SurfacePartRequest*) request.request_data;

Expand Down Expand Up @@ -517,6 +521,7 @@ SDLLightmap::draw_surface_part(const DrawingRequest& request)
int dstx = (int) request.pos.x * numerator / denominator;
int dsty = (int) request.pos.y * numerator / denominator;
light_blit(transform, &src_rect, dstx, dsty);
#endif
}

void
Expand Down
1 change: 0 additions & 1 deletion src/video/sdl/sdl_lightmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class SDLLightmap : public Lightmap
void get_light(const DrawingRequest& request) const;

private:
SDL_Surface* screen;
Uint8 *red_channel;
Uint8 *blue_channel;
Uint8 *green_channel;
Expand Down
Loading

0 comments on commit 0b1e736

Please sign in to comment.