mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-18 05:16:19 +01:00
Fix some build issues
This commit is contained in:
parent
abc77018aa
commit
d488764a7b
8
Makefile
8
Makefile
@ -1,4 +1,8 @@
|
|||||||
OBJS=menu.o
|
OBJS=menu.oo
|
||||||
|
|
||||||
|
%.oo: %.cpp
|
||||||
|
g++ `sdl-config --cflags` -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
menu: $(OBJS)
|
menu: $(OBJS)
|
||||||
g++ -lsdl -lsdl_image -lsdl_ttf -o $@ $+
|
g++ `sdl-config --libs` -lsdl -lsdl_image -lsdl_ttf -o $@ $+
|
||||||
|
35
menu.cpp
35
menu.cpp
@ -65,37 +65,44 @@ void Menu::printText(SDL_Surface *where, const char *msg, SDL_Color clr,
|
|||||||
SDL_FreeSurface(font_surf);
|
SDL_FreeSurface(font_surf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::highlightBackground(int x, int y, int w, int h)
|
void Menu::highlightBackground(SDL_Surface *where, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
|
SDL_Rect dst;
|
||||||
|
|
||||||
/* Can't highlight without images */
|
/* Can't highlight without images */
|
||||||
if (!this->text_bg_left ||
|
if (!this->text_bg_left ||
|
||||||
!this->text_bg_middle ||
|
!this->text_bg_middle ||
|
||||||
!this->text_bg_right)
|
!this->text_bg_right)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int font_height = TTF_FontHeight(this->font);
|
||||||
int bg_y_start = y + font_height / 2 -
|
int bg_y_start = y + font_height / 2 -
|
||||||
this->text_bg_left->h / 2;
|
this->text_bg_left->h / 2;
|
||||||
int bg_x_start = x - this->text_bg_right / 2;
|
int bg_x_start = x - this->text_bg_right->w / 2;
|
||||||
int bg_x_end = x + w -
|
int bg_x_end = x + w -
|
||||||
this->text_bg_right / 2;
|
this->text_bg_right->w / 2;
|
||||||
int n_mid = this->text_bg_left->w + this->text_bg_right->w -
|
int n_mid = this->text_bg_left->w + this->text_bg_right->w -
|
||||||
this->text_bg_middle->w;
|
this->text_bg_middle->w;
|
||||||
|
|
||||||
|
dst = (SDL_Rect){bg_x_start, bg_y_start, 0,0};
|
||||||
SDL_BlitSurface(this->text_bg_left, NULL,
|
SDL_BlitSurface(this->text_bg_left, NULL,
|
||||||
where, (SDL_Rect){bg_x_start, bg_y_start, 0,0});
|
where, &dst);
|
||||||
for (int i = 1; i < n_mid; i++)
|
for (int i = 1; i < n_mid; i++)
|
||||||
|
{
|
||||||
|
dst = (SDL_Rect){bg_x_start + i * this->text_bg_middle->w,
|
||||||
|
bg_y_start, 0,0};
|
||||||
SDL_BlitSurface(this->text_bg_middle, NULL,
|
SDL_BlitSurface(this->text_bg_middle, NULL,
|
||||||
where,
|
where, &dst);
|
||||||
(SDL_Rect){bg_x_start + i * this->text_bg_middle->w,
|
}
|
||||||
bg_y_start, 0,0});
|
dst = (SDL_Rect){bg_x_end, bg_y_start, 0,0};
|
||||||
SDL_BlitSurface(this->text_bg_right, NULL,
|
SDL_BlitSurface(this->text_bg_right, NULL,
|
||||||
where, (SDL_Rect){bg_x_end, bg_y_start, 0,0});
|
where, &dst);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::draw(SDL_Surface *where, int x, int y, int w, int h)
|
void Menu::draw(SDL_Surface *where, int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
int font_height = TTF_FontHeight(this->p_font);
|
int font_height = TTF_FontHeight(this->font);
|
||||||
int line_height = (font_height + font_height / 4);
|
int line_height = (font_height + font_height / 4);
|
||||||
int x_start = x;
|
int x_start = x;
|
||||||
int y_start = y + line_height;
|
int y_start = y + line_height;
|
||||||
@ -117,7 +124,7 @@ void Menu::draw(SDL_Surface *where, int x, int y, int w, int h)
|
|||||||
else if ( this->cur_sel < this->start_entry_visible )
|
else if ( this->cur_sel < this->start_entry_visible )
|
||||||
this->start_entry_visible = this->cur_sel;
|
this->start_entry_visible = this->cur_sel;
|
||||||
|
|
||||||
for (i = this->start_entry_visible;
|
for (int i = this->start_entry_visible;
|
||||||
i <= this->start_entry_visible + entries_visible; i++)
|
i <= this->start_entry_visible + entries_visible; i++)
|
||||||
{
|
{
|
||||||
const char *msg = this->pp_msgs[i];
|
const char *msg = this->pp_msgs[i];
|
||||||
@ -133,12 +140,12 @@ void Menu::draw(SDL_Surface *where, int x, int y, int w, int h)
|
|||||||
int tw, th;
|
int tw, th;
|
||||||
TTF_SizeText(this->font, msg, &tw, &th);
|
TTF_SizeText(this->font, msg, &tw, &th);
|
||||||
|
|
||||||
this->highlightBackground(x_start, cur_y, tw, th);
|
this->highlightBackground(where, x_start, cur_y, tw, th);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And print the text on top */
|
/* And print the text on top */
|
||||||
this->printText(msg, this->text_color,
|
this->printText(where, msg, this->text_color,
|
||||||
x_start, y_start + y, w);
|
x_start, y_start + y, w, h);
|
||||||
|
|
||||||
if (IS_SUBMENU(msg))
|
if (IS_SUBMENU(msg))
|
||||||
{
|
{
|
||||||
@ -167,7 +174,7 @@ void Menu::draw(SDL_Surface *where, int x, int y, int w, int h)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = xmalloc(total_chars + 1);
|
p = (char*)xmalloc(total_chars + 1);
|
||||||
strncpy(p, msg, total_chars);
|
strncpy(p, msg, total_chars);
|
||||||
TTF_SizeText(this->font, p, &tw_first, &th_first);
|
TTF_SizeText(this->font, p, &tw_first, &th_first);
|
||||||
|
|
||||||
|
2
menu.hh
2
menu.hh
@ -65,7 +65,7 @@ public:
|
|||||||
~Menu();
|
~Menu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void highlightBackground(int x, int y, int w, int h);
|
void highlightBackground(SDL_Surface *where, int x, int y, int w, int h);
|
||||||
|
|
||||||
void printText(SDL_Surface *where, const char *msg, SDL_Color clr,
|
void printText(SDL_Surface *where, const char *msg, SDL_Color clr,
|
||||||
int x, int y, int w, int h);
|
int x, int y, int w, int h);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user