Finished re-implementing OptionListComponent.

More new art to go with it (thanks Nils!).
This commit is contained in:
Aloshi 2014-03-06 13:45:03 -06:00
parent d0dfe480fa
commit 3ba7cd1247
13 changed files with 537 additions and 31 deletions

View file

@ -308,6 +308,9 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/data/converted/help_left_right_png.cpp
${CMAKE_CURRENT_SOURCE_DIR}/data/converted/opensans_hebrew_condensed_regular_ttf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/data/converted/sq_bracket_png.cpp
${CMAKE_CURRENT_SOURCE_DIR}/data/converted/arrow_png.cpp
${CMAKE_CURRENT_SOURCE_DIR}/data/converted/checkbox_checked_png.cpp
${CMAKE_CURRENT_SOURCE_DIR}/data/converted/checkbox_unchecked_png.cpp
)
SOURCE_GROUP(resources FILES ResourceUtil.cpp)

View file

@ -2,9 +2,12 @@
#include "Resources.h"
const size_t res2hNrOfFiles = 17;
const size_t res2hNrOfFiles = 20;
const Res2hEntry res2hFiles[res2hNrOfFiles] = {
{":/arrow.png", arrow_png_size, arrow_png_data},
{":/button.png", button_png_size, button_png_data},
{":/checkbox_checked.png", checkbox_checked_png_size, checkbox_checked_png_data},
{":/checkbox_unchecked.png", checkbox_unchecked_png_size, checkbox_unchecked_png_data},
{":/ES_logo_16.png", ES_logo_16_png_size, ES_logo_16_png_data},
{":/ES_logo_32.png", ES_logo_32_png_size, ES_logo_32_png_data},
{":/frame.png", frame_png_size, frame_png_data},
@ -24,23 +27,26 @@ const Res2hEntry res2hFiles[res2hNrOfFiles] = {
};
res2hMapType::value_type mapTemp[] = {
std::make_pair(":/button.png", res2hFiles[0]),
std::make_pair(":/ES_logo_16.png", res2hFiles[1]),
std::make_pair(":/ES_logo_32.png", res2hFiles[2]),
std::make_pair(":/frame.png", res2hFiles[3]),
std::make_pair(":/opensans_hebrew_condensed_regular.ttf", res2hFiles[4]),
std::make_pair(":/scroll_gradient.png", res2hFiles[5]),
std::make_pair(":/sq_bracket.png", res2hFiles[6]),
std::make_pair(":/star_filled.png", res2hFiles[7]),
std::make_pair(":/star_unfilled.png", res2hFiles[8]),
std::make_pair(":/textbox.png", res2hFiles[9]),
std::make_pair(":/textbox_glow.png", res2hFiles[10]),
std::make_pair(":/help/a.png", res2hFiles[11]),
std::make_pair(":/help/b.png", res2hFiles[12]),
std::make_pair(":/help/dpad.png", res2hFiles[13]),
std::make_pair(":/help/left_right.png", res2hFiles[14]),
std::make_pair(":/help/menu.png", res2hFiles[15]),
std::make_pair(":/help/up_down.png", res2hFiles[16])
std::make_pair(":/arrow.png", res2hFiles[0]),
std::make_pair(":/button.png", res2hFiles[1]),
std::make_pair(":/checkbox_checked.png", res2hFiles[2]),
std::make_pair(":/checkbox_unchecked.png", res2hFiles[3]),
std::make_pair(":/ES_logo_16.png", res2hFiles[4]),
std::make_pair(":/ES_logo_32.png", res2hFiles[5]),
std::make_pair(":/frame.png", res2hFiles[6]),
std::make_pair(":/opensans_hebrew_condensed_regular.ttf", res2hFiles[7]),
std::make_pair(":/scroll_gradient.png", res2hFiles[8]),
std::make_pair(":/sq_bracket.png", res2hFiles[9]),
std::make_pair(":/star_filled.png", res2hFiles[10]),
std::make_pair(":/star_unfilled.png", res2hFiles[11]),
std::make_pair(":/textbox.png", res2hFiles[12]),
std::make_pair(":/textbox_glow.png", res2hFiles[13]),
std::make_pair(":/help/a.png", res2hFiles[14]),
std::make_pair(":/help/b.png", res2hFiles[15]),
std::make_pair(":/help/dpad.png", res2hFiles[16]),
std::make_pair(":/help/left_right.png", res2hFiles[17]),
std::make_pair(":/help/menu.png", res2hFiles[18]),
std::make_pair(":/help/up_down.png", res2hFiles[19])
};
res2hMapType res2hMap(mapTemp, mapTemp + sizeof mapTemp / sizeof mapTemp[0]);

View file

@ -5,9 +5,18 @@
#include <string>
#include <map>
extern const size_t arrow_png_size;
extern const unsigned char arrow_png_data[];
extern const size_t button_png_size;
extern const unsigned char button_png_data[];
extern const size_t checkbox_checked_png_size;
extern const unsigned char checkbox_checked_png_data[];
extern const size_t checkbox_unchecked_png_size;
extern const unsigned char checkbox_unchecked_png_data[];
extern const size_t ES_logo_16_png_size;
extern const unsigned char ES_logo_16_png_data[];

View file

@ -0,0 +1,127 @@
//this file was auto-generated from "arrow.png" by res2h
#include "../Resources.h"
const size_t arrow_png_size = 1193;
const unsigned char arrow_png_data[1193] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,
0x00,0x0d,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0x0c,
0x00,0x00,0x00,0x16,0x08,0x06,0x00,0x00,0x00,0xf4,
0x38,0x7d,0x1a,0x00,0x00,0x00,0x19,0x74,0x45,0x58,
0x74,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,0x00,
0x41,0x64,0x6f,0x62,0x65,0x20,0x49,0x6d,0x61,0x67,
0x65,0x52,0x65,0x61,0x64,0x79,0x71,0xc9,0x65,0x3c,
0x00,0x00,0x03,0x24,0x69,0x54,0x58,0x74,0x58,0x4d,
0x4c,0x3a,0x63,0x6f,0x6d,0x2e,0x61,0x64,0x6f,0x62,
0x65,0x2e,0x78,0x6d,0x70,0x00,0x00,0x00,0x00,0x00,
0x3c,0x3f,0x78,0x70,0x61,0x63,0x6b,0x65,0x74,0x20,
0x62,0x65,0x67,0x69,0x6e,0x3d,0x22,0xef,0xbb,0xbf,
0x22,0x20,0x69,0x64,0x3d,0x22,0x57,0x35,0x4d,0x30,
0x4d,0x70,0x43,0x65,0x68,0x69,0x48,0x7a,0x72,0x65,
0x53,0x7a,0x4e,0x54,0x63,0x7a,0x6b,0x63,0x39,0x64,
0x22,0x3f,0x3e,0x20,0x3c,0x78,0x3a,0x78,0x6d,0x70,
0x6d,0x65,0x74,0x61,0x20,0x78,0x6d,0x6c,0x6e,0x73,
0x3a,0x78,0x3d,0x22,0x61,0x64,0x6f,0x62,0x65,0x3a,
0x6e,0x73,0x3a,0x6d,0x65,0x74,0x61,0x2f,0x22,0x20,
0x78,0x3a,0x78,0x6d,0x70,0x74,0x6b,0x3d,0x22,0x41,
0x64,0x6f,0x62,0x65,0x20,0x58,0x4d,0x50,0x20,0x43,
0x6f,0x72,0x65,0x20,0x35,0x2e,0x33,0x2d,0x63,0x30,
0x31,0x31,0x20,0x36,0x36,0x2e,0x31,0x34,0x35,0x36,
0x36,0x31,0x2c,0x20,0x32,0x30,0x31,0x32,0x2f,0x30,
0x32,0x2f,0x30,0x36,0x2d,0x31,0x34,0x3a,0x35,0x36,
0x3a,0x32,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x22,0x3e,0x20,0x3c,0x72,0x64,0x66,0x3a,0x52,
0x44,0x46,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x72,
0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,
0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,
0x67,0x2f,0x31,0x39,0x39,0x39,0x2f,0x30,0x32,0x2f,
0x32,0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e,
0x74,0x61,0x78,0x2d,0x6e,0x73,0x23,0x22,0x3e,0x20,
0x3c,0x72,0x64,0x66,0x3a,0x44,0x65,0x73,0x63,0x72,
0x69,0x70,0x74,0x69,0x6f,0x6e,0x20,0x72,0x64,0x66,
0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x22,0x20,
0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6d,0x70,0x3d,
0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,
0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,
0x2f,0x78,0x61,0x70,0x2f,0x31,0x2e,0x30,0x2f,0x22,
0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6d,0x70,
0x4d,0x4d,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,
0x2f,0x6e,0x73,0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,
0x63,0x6f,0x6d,0x2f,0x78,0x61,0x70,0x2f,0x31,0x2e,
0x30,0x2f,0x6d,0x6d,0x2f,0x22,0x20,0x78,0x6d,0x6c,
0x6e,0x73,0x3a,0x73,0x74,0x52,0x65,0x66,0x3d,0x22,
0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,
0x61,0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,0x2f,
0x78,0x61,0x70,0x2f,0x31,0x2e,0x30,0x2f,0x73,0x54,
0x79,0x70,0x65,0x2f,0x52,0x65,0x73,0x6f,0x75,0x72,
0x63,0x65,0x52,0x65,0x66,0x23,0x22,0x20,0x78,0x6d,
0x70,0x3a,0x43,0x72,0x65,0x61,0x74,0x6f,0x72,0x54,
0x6f,0x6f,0x6c,0x3d,0x22,0x41,0x64,0x6f,0x62,0x65,
0x20,0x50,0x68,0x6f,0x74,0x6f,0x73,0x68,0x6f,0x70,
0x20,0x43,0x53,0x36,0x20,0x28,0x4d,0x61,0x63,0x69,
0x6e,0x74,0x6f,0x73,0x68,0x29,0x22,0x20,0x78,0x6d,
0x70,0x4d,0x4d,0x3a,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x69,0x69,0x64,0x3a,0x39,0x33,0x41,0x30,0x43,0x42,
0x45,0x30,0x39,0x44,0x37,0x45,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x20,0x78,0x6d,
0x70,0x4d,0x4d,0x3a,0x44,0x6f,0x63,0x75,0x6d,0x65,
0x6e,0x74,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x64,0x69,0x64,0x3a,0x39,0x33,0x41,0x30,0x43,0x42,
0x45,0x31,0x39,0x44,0x37,0x45,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x3e,0x20,0x3c,
0x78,0x6d,0x70,0x4d,0x4d,0x3a,0x44,0x65,0x72,0x69,
0x76,0x65,0x64,0x46,0x72,0x6f,0x6d,0x20,0x73,0x74,
0x52,0x65,0x66,0x3a,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x69,0x69,0x64,0x3a,0x43,0x36,0x39,0x45,0x38,0x46,
0x46,0x46,0x39,0x44,0x37,0x44,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x20,0x73,0x74,
0x52,0x65,0x66,0x3a,0x64,0x6f,0x63,0x75,0x6d,0x65,
0x6e,0x74,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x64,0x69,0x64,0x3a,0x43,0x36,0x39,0x45,0x39,0x30,
0x30,0x30,0x39,0x44,0x37,0x44,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x2f,0x3e,0x20,
0x3c,0x2f,0x72,0x64,0x66,0x3a,0x44,0x65,0x73,0x63,
0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0x20,0x3c,
0x2f,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x3e,0x20,
0x3c,0x2f,0x78,0x3a,0x78,0x6d,0x70,0x6d,0x65,0x74,
0x61,0x3e,0x20,0x3c,0x3f,0x78,0x70,0x61,0x63,0x6b,
0x65,0x74,0x20,0x65,0x6e,0x64,0x3d,0x22,0x72,0x22,
0x3f,0x3e,0x28,0xbb,0x69,0xeb,0x00,0x00,0x01,0x1b,
0x49,0x44,0x41,0x54,0x78,0xda,0x8c,0xd3,0xbf,0x4b,
0x02,0x61,0x1c,0xc7,0xf1,0xa7,0x43,0xa4,0x20,0x50,
0x70,0xd1,0x21,0x87,0x68,0x69,0x91,0x36,0x17,0xc5,
0x45,0xc2,0xa1,0x82,0x26,0x83,0x20,0x6a,0x69,0xb0,
0x2d,0x82,0xdb,0xfa,0x0f,0x6c,0x11,0xda,0x92,0x70,
0x73,0xa8,0x10,0x0a,0xaa,0x29,0xd1,0xa5,0x2d,0x5a,
0x5a,0x04,0xc1,0x06,0x11,0x12,0x24,0x82,0x24,0x14,
0x7b,0x3f,0xf0,0x08,0xc7,0xc1,0xdd,0x7d,0xbf,0xf0,
0x9a,0xee,0xfb,0xb9,0xe7,0xf7,0x82,0x6d,0xdb,0x65,
0xa5,0xd4,0x19,0x66,0x4a,0x50,0x16,0x4e,0x71,0x8d,
0x90,0x34,0xa0,0xeb,0x00,0x77,0x58,0x92,0x06,0x74,
0x6d,0xe1,0x19,0x51,0x69,0xa0,0x87,0x0c,0x9a,0x48,
0x48,0x02,0xba,0xf9,0x03,0x29,0xb4,0xb1,0x16,0x14,
0xf8,0x44,0x16,0xaf,0x58,0x45,0x0b,0x1b,0x7e,0x01,
0x5d,0x43,0xe4,0xcd,0x5a,0xe2,0x78,0x41,0xce,0x2f,
0xa0,0xeb,0x07,0xdb,0xa8,0x23,0x82,0x47,0xec,0xf8,
0x05,0x74,0xfd,0x61,0x1f,0x97,0x58,0xc4,0x2d,0x8e,
0x54,0xc0,0x61,0x4d,0x71,0x82,0x2f,0x9c,0xe3,0x0a,
0x31,0x4b,0x70,0xb8,0xce,0x2b,0x63,0x85,0x02,0xce,
0xa8,0x82,0x92,0x19,0xed,0x18,0x55,0xaf,0x40,0x18,
0x35,0x14,0x31,0xc6,0x1e,0x1a,0x5e,0x6b,0x58,0xc6,
0x0d,0x36,0xf1,0x6d,0x76,0xa8,0x39,0xff,0xe8,0x0e,
0xc4,0xf0,0x80,0x34,0x06,0x28,0xe0,0xcd,0xd9,0xe0,
0x0c,0xac,0xe0,0x09,0xeb,0xe8,0x9a,0x11,0x3a,0xee,
0xe1,0x9d,0x01,0x7d,0x7f,0x92,0x78,0x37,0x7f,0xee,
0x07,0xdd,0xa5,0xa4,0x09,0xe5,0xbc,0x9a,0xdd,0x81,
0x7b,0x33,0x8d,0x91,0xe4,0x3d,0xe8,0x2d,0xdc,0xc5,
0xaf,0xe4,0xc5,0x5d,0xe0,0x10,0x13,0xc9,0x9b,0xfe,
0x17,0x60,0x00,0x1d,0x24,0x35,0x2f,0xfe,0xb0,0x0a,
0xfe,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,
0x42,0x60,0x82
};

View file

@ -0,0 +1,137 @@
//this file was auto-generated from "checkbox_checked.png" by res2h
#include "../Resources.h"
const size_t checkbox_checked_png_size = 1296;
const unsigned char checkbox_checked_png_data[1296] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,
0x00,0x0d,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0x18,
0x00,0x00,0x00,0x18,0x08,0x06,0x00,0x00,0x00,0xe0,
0x77,0x3d,0xf8,0x00,0x00,0x00,0x19,0x74,0x45,0x58,
0x74,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,0x00,
0x41,0x64,0x6f,0x62,0x65,0x20,0x49,0x6d,0x61,0x67,
0x65,0x52,0x65,0x61,0x64,0x79,0x71,0xc9,0x65,0x3c,
0x00,0x00,0x03,0x24,0x69,0x54,0x58,0x74,0x58,0x4d,
0x4c,0x3a,0x63,0x6f,0x6d,0x2e,0x61,0x64,0x6f,0x62,
0x65,0x2e,0x78,0x6d,0x70,0x00,0x00,0x00,0x00,0x00,
0x3c,0x3f,0x78,0x70,0x61,0x63,0x6b,0x65,0x74,0x20,
0x62,0x65,0x67,0x69,0x6e,0x3d,0x22,0xef,0xbb,0xbf,
0x22,0x20,0x69,0x64,0x3d,0x22,0x57,0x35,0x4d,0x30,
0x4d,0x70,0x43,0x65,0x68,0x69,0x48,0x7a,0x72,0x65,
0x53,0x7a,0x4e,0x54,0x63,0x7a,0x6b,0x63,0x39,0x64,
0x22,0x3f,0x3e,0x20,0x3c,0x78,0x3a,0x78,0x6d,0x70,
0x6d,0x65,0x74,0x61,0x20,0x78,0x6d,0x6c,0x6e,0x73,
0x3a,0x78,0x3d,0x22,0x61,0x64,0x6f,0x62,0x65,0x3a,
0x6e,0x73,0x3a,0x6d,0x65,0x74,0x61,0x2f,0x22,0x20,
0x78,0x3a,0x78,0x6d,0x70,0x74,0x6b,0x3d,0x22,0x41,
0x64,0x6f,0x62,0x65,0x20,0x58,0x4d,0x50,0x20,0x43,
0x6f,0x72,0x65,0x20,0x35,0x2e,0x33,0x2d,0x63,0x30,
0x31,0x31,0x20,0x36,0x36,0x2e,0x31,0x34,0x35,0x36,
0x36,0x31,0x2c,0x20,0x32,0x30,0x31,0x32,0x2f,0x30,
0x32,0x2f,0x30,0x36,0x2d,0x31,0x34,0x3a,0x35,0x36,
0x3a,0x32,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x22,0x3e,0x20,0x3c,0x72,0x64,0x66,0x3a,0x52,
0x44,0x46,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x72,
0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,
0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,
0x67,0x2f,0x31,0x39,0x39,0x39,0x2f,0x30,0x32,0x2f,
0x32,0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e,
0x74,0x61,0x78,0x2d,0x6e,0x73,0x23,0x22,0x3e,0x20,
0x3c,0x72,0x64,0x66,0x3a,0x44,0x65,0x73,0x63,0x72,
0x69,0x70,0x74,0x69,0x6f,0x6e,0x20,0x72,0x64,0x66,
0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x22,0x20,
0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6d,0x70,0x3d,
0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,
0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,
0x2f,0x78,0x61,0x70,0x2f,0x31,0x2e,0x30,0x2f,0x22,
0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6d,0x70,
0x4d,0x4d,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,
0x2f,0x6e,0x73,0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,
0x63,0x6f,0x6d,0x2f,0x78,0x61,0x70,0x2f,0x31,0x2e,
0x30,0x2f,0x6d,0x6d,0x2f,0x22,0x20,0x78,0x6d,0x6c,
0x6e,0x73,0x3a,0x73,0x74,0x52,0x65,0x66,0x3d,0x22,
0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,
0x61,0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,0x2f,
0x78,0x61,0x70,0x2f,0x31,0x2e,0x30,0x2f,0x73,0x54,
0x79,0x70,0x65,0x2f,0x52,0x65,0x73,0x6f,0x75,0x72,
0x63,0x65,0x52,0x65,0x66,0x23,0x22,0x20,0x78,0x6d,
0x70,0x3a,0x43,0x72,0x65,0x61,0x74,0x6f,0x72,0x54,
0x6f,0x6f,0x6c,0x3d,0x22,0x41,0x64,0x6f,0x62,0x65,
0x20,0x50,0x68,0x6f,0x74,0x6f,0x73,0x68,0x6f,0x70,
0x20,0x43,0x53,0x36,0x20,0x28,0x4d,0x61,0x63,0x69,
0x6e,0x74,0x6f,0x73,0x68,0x29,0x22,0x20,0x78,0x6d,
0x70,0x4d,0x4d,0x3a,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x69,0x69,0x64,0x3a,0x32,0x39,0x46,0x39,0x36,0x42,
0x42,0x44,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x20,0x78,0x6d,
0x70,0x4d,0x4d,0x3a,0x44,0x6f,0x63,0x75,0x6d,0x65,
0x6e,0x74,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x64,0x69,0x64,0x3a,0x32,0x39,0x46,0x39,0x36,0x42,
0x42,0x45,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x3e,0x20,0x3c,
0x78,0x6d,0x70,0x4d,0x4d,0x3a,0x44,0x65,0x72,0x69,
0x76,0x65,0x64,0x46,0x72,0x6f,0x6d,0x20,0x73,0x74,
0x52,0x65,0x66,0x3a,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x69,0x69,0x64,0x3a,0x30,0x31,0x33,0x32,0x33,0x39,
0x44,0x45,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x20,0x73,0x74,
0x52,0x65,0x66,0x3a,0x64,0x6f,0x63,0x75,0x6d,0x65,
0x6e,0x74,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x64,0x69,0x64,0x3a,0x32,0x39,0x46,0x39,0x36,0x42,
0x42,0x43,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x2f,0x3e,0x20,
0x3c,0x2f,0x72,0x64,0x66,0x3a,0x44,0x65,0x73,0x63,
0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0x20,0x3c,
0x2f,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x3e,0x20,
0x3c,0x2f,0x78,0x3a,0x78,0x6d,0x70,0x6d,0x65,0x74,
0x61,0x3e,0x20,0x3c,0x3f,0x78,0x70,0x61,0x63,0x6b,
0x65,0x74,0x20,0x65,0x6e,0x64,0x3d,0x22,0x72,0x22,
0x3f,0x3e,0xf8,0x79,0xf8,0xc2,0x00,0x00,0x01,0x82,
0x49,0x44,0x41,0x54,0x78,0xda,0xac,0x95,0xbd,0x4a,
0x03,0x41,0x14,0x85,0x67,0x27,0xdb,0x5b,0xad,0x8d,
0xf6,0x29,0x62,0xa7,0x85,0x82,0x16,0x82,0xe0,0x03,
0x88,0xb1,0xd2,0xda,0xc2,0xc2,0x6e,0xbb,0xa0,0x79,
0x03,0x51,0xc8,0xd6,0x5a,0x45,0xf4,0x19,0x2c,0x22,
0x68,0xa1,0xa5,0x90,0xf4,0x6a,0x61,0x1a,0xd3,0x1b,
0xd6,0x73,0xe5,0x2c,0x0c,0x61,0x9c,0xdc,0x64,0xf7,
0xc2,0x97,0xd9,0x09,0x73,0xcf,0xd9,0xf9,0xb9,0x3b,
0x51,0x9a,0xa6,0x06,0xb1,0x00,0xce,0xc0,0x1e,0x58,
0x06,0x91,0x99,0x2f,0x72,0xf0,0x01,0xee,0xc0,0x39,
0xf8,0x8e,0x29,0xfe,0x08,0x56,0x4c,0xf9,0x88,0xf8,
0x82,0xa7,0x60,0x07,0x6c,0x5a,0xfc,0xb4,0x28,0xde,
0x07,0x1b,0x20,0xe6,0xc0,0x79,0x88,0xa9,0xd1,0xa7,
0x66,0x4b,0x0c,0xf6,0xe9,0x7e,0x04,0x9e,0xc1,0xb8,
0xc4,0x0c,0xc6,0xd4,0x38,0x64,0xbf,0x69,0x39,0x25,
0x89,0x17,0x67,0xe0,0x31,0x48,0x66,0x10,0x4e,0x98,
0x53,0xc4,0x2b,0xdb,0x25,0xeb,0x6c,0x68,0xce,0xf6,
0x04,0x74,0xc0,0x83,0xd2,0x24,0xe1,0xd8,0x0e,0x73,
0x5d,0xad,0xc8,0x7a,0x12,0x6e,0xc1,0x1b,0x68,0x28,
0x4c,0x0a,0xf1,0x06,0x73,0xba,0x93,0x03,0x7c,0x06,
0x5f,0x60,0x5b,0x61,0x32,0x29,0x2e,0x39,0x43,0x8d,
0x81,0xe1,0xc0,0x90,0x89,0x4a,0x3c,0x64,0x10,0x32,
0x51,0x8b,0x1b,0x9e,0x5b,0xa3,0x30,0x29,0x04,0x7b,
0xfc,0xbf,0xae,0x11,0xd7,0x18,0xb8,0x26,0x3d,0x0a,
0x4b,0x0c,0x34,0xe2,0xd3,0x96,0xa8,0x92,0xb0,0x33,
0x9c,0xf3,0x3a,0xdf,0x7c,0xc0,0x67,0x55,0x9d,0x58,
0xa5,0x78,0xb1,0xa1,0x5b,0x44,0x5b,0x27,0x41,0x83,
0xff,0x4e,0xcb,0x50,0x59,0x27,0x41,0x83,0x69,0x47,
0x51,0x6d,0xe2,0x33,0x58,0x54,0x9e,0x73,0x95,0x89,
0xcf,0xa0,0xa9,0x2d,0x22,0x8f,0xc9,0x81,0xaf,0x0e,
0x72,0xe7,0xc2,0x90,0xe7,0x2b,0xf0,0x03,0xee,0x35,
0xe7,0xdc,0x31,0x91,0xeb,0x36,0x73,0x6e,0xb6,0xbf,
0xaf,0xaa,0xe5,0x1d,0x2a,0xb1,0xe6,0x24,0x65,0x4a,
0x71,0xd7,0x24,0x73,0xfa,0xab,0x6c,0x3f,0x2d,0x3f,
0xcf,0x12,0xd7,0x60,0x1d,0xd4,0x4a,0xd4,0x55,0x8d,
0x1a,0x37,0xec,0x77,0x65,0x89,0xda,0x60,0x97,0x6b,
0xf8,0x54,0x61,0x11,0xcb,0xbe,0xb4,0x65,0x06,0x23,
0xb9,0xfd,0xc1,0x05,0x78,0xaf,0x40,0x58,0x34,0x2e,
0xa9,0x39,0xfa,0x15,0x60,0x00,0x12,0x0c,0x71,0x62,
0xd6,0x69,0x05,0x82,0x00,0x00,0x00,0x00,0x49,0x45,
0x4e,0x44,0xae,0x42,0x60,0x82
};

View file

@ -0,0 +1,121 @@
//this file was auto-generated from "checkbox_unchecked.png" by res2h
#include "../Resources.h"
const size_t checkbox_unchecked_png_size = 1131;
const unsigned char checkbox_unchecked_png_data[1131] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,
0x00,0x0d,0x49,0x48,0x44,0x52,0x00,0x00,0x00,0x18,
0x00,0x00,0x00,0x18,0x08,0x06,0x00,0x00,0x00,0xe0,
0x77,0x3d,0xf8,0x00,0x00,0x00,0x19,0x74,0x45,0x58,
0x74,0x53,0x6f,0x66,0x74,0x77,0x61,0x72,0x65,0x00,
0x41,0x64,0x6f,0x62,0x65,0x20,0x49,0x6d,0x61,0x67,
0x65,0x52,0x65,0x61,0x64,0x79,0x71,0xc9,0x65,0x3c,
0x00,0x00,0x03,0x24,0x69,0x54,0x58,0x74,0x58,0x4d,
0x4c,0x3a,0x63,0x6f,0x6d,0x2e,0x61,0x64,0x6f,0x62,
0x65,0x2e,0x78,0x6d,0x70,0x00,0x00,0x00,0x00,0x00,
0x3c,0x3f,0x78,0x70,0x61,0x63,0x6b,0x65,0x74,0x20,
0x62,0x65,0x67,0x69,0x6e,0x3d,0x22,0xef,0xbb,0xbf,
0x22,0x20,0x69,0x64,0x3d,0x22,0x57,0x35,0x4d,0x30,
0x4d,0x70,0x43,0x65,0x68,0x69,0x48,0x7a,0x72,0x65,
0x53,0x7a,0x4e,0x54,0x63,0x7a,0x6b,0x63,0x39,0x64,
0x22,0x3f,0x3e,0x20,0x3c,0x78,0x3a,0x78,0x6d,0x70,
0x6d,0x65,0x74,0x61,0x20,0x78,0x6d,0x6c,0x6e,0x73,
0x3a,0x78,0x3d,0x22,0x61,0x64,0x6f,0x62,0x65,0x3a,
0x6e,0x73,0x3a,0x6d,0x65,0x74,0x61,0x2f,0x22,0x20,
0x78,0x3a,0x78,0x6d,0x70,0x74,0x6b,0x3d,0x22,0x41,
0x64,0x6f,0x62,0x65,0x20,0x58,0x4d,0x50,0x20,0x43,
0x6f,0x72,0x65,0x20,0x35,0x2e,0x33,0x2d,0x63,0x30,
0x31,0x31,0x20,0x36,0x36,0x2e,0x31,0x34,0x35,0x36,
0x36,0x31,0x2c,0x20,0x32,0x30,0x31,0x32,0x2f,0x30,
0x32,0x2f,0x30,0x36,0x2d,0x31,0x34,0x3a,0x35,0x36,
0x3a,0x32,0x37,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x22,0x3e,0x20,0x3c,0x72,0x64,0x66,0x3a,0x52,
0x44,0x46,0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x72,
0x64,0x66,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,
0x2f,0x77,0x77,0x77,0x2e,0x77,0x33,0x2e,0x6f,0x72,
0x67,0x2f,0x31,0x39,0x39,0x39,0x2f,0x30,0x32,0x2f,
0x32,0x32,0x2d,0x72,0x64,0x66,0x2d,0x73,0x79,0x6e,
0x74,0x61,0x78,0x2d,0x6e,0x73,0x23,0x22,0x3e,0x20,
0x3c,0x72,0x64,0x66,0x3a,0x44,0x65,0x73,0x63,0x72,
0x69,0x70,0x74,0x69,0x6f,0x6e,0x20,0x72,0x64,0x66,
0x3a,0x61,0x62,0x6f,0x75,0x74,0x3d,0x22,0x22,0x20,
0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6d,0x70,0x3d,
0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,
0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,
0x2f,0x78,0x61,0x70,0x2f,0x31,0x2e,0x30,0x2f,0x22,
0x20,0x78,0x6d,0x6c,0x6e,0x73,0x3a,0x78,0x6d,0x70,
0x4d,0x4d,0x3d,0x22,0x68,0x74,0x74,0x70,0x3a,0x2f,
0x2f,0x6e,0x73,0x2e,0x61,0x64,0x6f,0x62,0x65,0x2e,
0x63,0x6f,0x6d,0x2f,0x78,0x61,0x70,0x2f,0x31,0x2e,
0x30,0x2f,0x6d,0x6d,0x2f,0x22,0x20,0x78,0x6d,0x6c,
0x6e,0x73,0x3a,0x73,0x74,0x52,0x65,0x66,0x3d,0x22,
0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x6e,0x73,0x2e,
0x61,0x64,0x6f,0x62,0x65,0x2e,0x63,0x6f,0x6d,0x2f,
0x78,0x61,0x70,0x2f,0x31,0x2e,0x30,0x2f,0x73,0x54,
0x79,0x70,0x65,0x2f,0x52,0x65,0x73,0x6f,0x75,0x72,
0x63,0x65,0x52,0x65,0x66,0x23,0x22,0x20,0x78,0x6d,
0x70,0x3a,0x43,0x72,0x65,0x61,0x74,0x6f,0x72,0x54,
0x6f,0x6f,0x6c,0x3d,0x22,0x41,0x64,0x6f,0x62,0x65,
0x20,0x50,0x68,0x6f,0x74,0x6f,0x73,0x68,0x6f,0x70,
0x20,0x43,0x53,0x36,0x20,0x28,0x4d,0x61,0x63,0x69,
0x6e,0x74,0x6f,0x73,0x68,0x29,0x22,0x20,0x78,0x6d,
0x70,0x4d,0x4d,0x3a,0x49,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x69,0x69,0x64,0x3a,0x30,0x31,0x33,0x32,0x33,0x39,
0x44,0x43,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x20,0x78,0x6d,
0x70,0x4d,0x4d,0x3a,0x44,0x6f,0x63,0x75,0x6d,0x65,
0x6e,0x74,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x64,0x69,0x64,0x3a,0x30,0x31,0x33,0x32,0x33,0x39,
0x44,0x44,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x3e,0x20,0x3c,
0x78,0x6d,0x70,0x4d,0x4d,0x3a,0x44,0x65,0x72,0x69,
0x76,0x65,0x64,0x46,0x72,0x6f,0x6d,0x20,0x73,0x74,
0x52,0x65,0x66,0x3a,0x69,0x6e,0x73,0x74,0x61,0x6e,
0x63,0x65,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x69,0x69,0x64,0x3a,0x30,0x31,0x33,0x32,0x33,0x39,
0x44,0x41,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x20,0x73,0x74,
0x52,0x65,0x66,0x3a,0x64,0x6f,0x63,0x75,0x6d,0x65,
0x6e,0x74,0x49,0x44,0x3d,0x22,0x78,0x6d,0x70,0x2e,
0x64,0x69,0x64,0x3a,0x30,0x31,0x33,0x32,0x33,0x39,
0x44,0x42,0x39,0x44,0x38,0x37,0x31,0x31,0x45,0x33,
0x41,0x39,0x31,0x44,0x42,0x44,0x46,0x44,0x34,0x30,
0x39,0x39,0x32,0x45,0x45,0x33,0x22,0x2f,0x3e,0x20,
0x3c,0x2f,0x72,0x64,0x66,0x3a,0x44,0x65,0x73,0x63,
0x72,0x69,0x70,0x74,0x69,0x6f,0x6e,0x3e,0x20,0x3c,
0x2f,0x72,0x64,0x66,0x3a,0x52,0x44,0x46,0x3e,0x20,
0x3c,0x2f,0x78,0x3a,0x78,0x6d,0x70,0x6d,0x65,0x74,
0x61,0x3e,0x20,0x3c,0x3f,0x78,0x70,0x61,0x63,0x6b,
0x65,0x74,0x20,0x65,0x6e,0x64,0x3d,0x22,0x72,0x22,
0x3f,0x3e,0xc7,0x8f,0x1f,0x43,0x00,0x00,0x00,0xdd,
0x49,0x44,0x41,0x54,0x78,0xda,0xec,0x95,0x31,0x0a,
0xc2,0x40,0x14,0x44,0x77,0x37,0xdb,0x7b,0x00,0xbd,
0x81,0x76,0x5a,0x28,0x58,0x0a,0x1e,0x40,0xb4,0xd3,
0x33,0xd8,0xa5,0x0b,0xea,0x0d,0xc4,0x1b,0x98,0x4a,
0xf1,0x18,0x82,0x16,0x5a,0x0a,0x39,0x80,0x5a,0x9b,
0x03,0x84,0x38,0x1f,0x46,0x49,0x9d,0xac,0x60,0xb1,
0x03,0x2f,0x61,0x21,0xbc,0xc9,0x27,0x90,0xaf,0xc3,
0x30,0x54,0x48,0x0d,0x2c,0xc0,0x08,0x34,0x80,0x56,
0xe5,0x92,0x83,0x07,0x38,0x80,0x25,0x78,0x59,0xca,
0x8f,0xa0,0xa5,0xaa,0x47,0xf3,0x05,0xe7,0x60,0x00,
0xfa,0x06,0x97,0x88,0xf2,0x04,0xf4,0x80,0xe5,0x83,
0x65,0xb0,0x74,0x24,0x74,0x46,0x52,0x30,0x66,0xfb,
0x0c,0x9c,0x41,0x56,0x61,0x82,0x8c,0x8e,0x29,0xcf,
0x13,0xc3,0x91,0x24,0x17,0xe5,0x2e,0x57,0xde,0xeb,
0xa6,0xf0,0x41,0x73,0x87,0x05,0x1f,0x97,0x36,0xea,
0xc7,0xf1,0x05,0xbe,0xc0,0x17,0xf8,0x82,0x7f,0x29,
0xc8,0x0b,0xdb,0xc8,0x55,0xbe,0x7f,0x68,0xc3,0x1d,
0x2a,0xe9,0x38,0x2c,0x68,0xf3,0xfe,0x94,0x82,0x3d,
0x0f,0x5b,0xd0,0x05,0x41,0x05,0x71,0x40,0x47,0xcc,
0xf3,0x4e,0x76,0xe8,0x0a,0x0c,0x41,0x13,0x9c,0x1c,
0x4e,0x71,0x13,0xb7,0x4c,0x90,0xca,0xf6,0x07,0x6b,
0x70,0x77,0x20,0x16,0xc7,0x86,0xce,0xf4,0x2d,0xc0,
0x00,0xa5,0x0f,0x24,0x89,0xc3,0x06,0x4f,0xc8,0x00,
0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,
0x82
};

BIN
data/resources/arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -8,7 +8,7 @@ ComponentList::ComponentList(Window* window) : IList<ComponentListRow, void*>(wi
mCameraOffset = 0;
}
void ComponentList::addRow(const ComponentListRow& row)
void ComponentList::addRow(const ComponentListRow& row, bool setCursorHere)
{
IList<ComponentListRow, void*>::Entry e;
e.name = "";
@ -22,6 +22,12 @@ void ComponentList::addRow(const ComponentListRow& row)
updateElementSize(mEntries.back().data);
updateElementPosition(mEntries.back().data);
if(setCursorHere)
{
mCursor = mEntries.size() - 1;
onCursorChanged(CURSOR_STOPPED);
}
}
void ComponentList::onSizeChanged()

View file

@ -45,7 +45,7 @@ class ComponentList : public IList<ComponentListRow, void*>
public:
ComponentList(Window* window);
void addRow(const ComponentListRow& row);
void addRow(const ComponentListRow& row, bool setCursorHere = false);
bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override;

View file

@ -11,7 +11,7 @@ public:
void onSizeChanged() override;
inline void addRow(const ComponentListRow& row) { mList.addRow(row); }
inline void addRow(const ComponentListRow& row, bool setCursorHere = false) { mList.addRow(row, setCursorHere); }
private:
NinePatchComponent mBackground;

View file

@ -5,8 +5,10 @@
#include "../Renderer.h"
#include "../Window.h"
#include "TextComponent.h"
#include "ImageComponent.h"
#include "MenuComponent.h"
#include <sstream>
#include "../Log.h"
//Used to display a list of options.
//Can select one or multiple options.
@ -36,16 +38,51 @@ private:
public:
OptionListPopup(Window* window, OptionListComponent<T>* parent) : GuiComponent(window),
mMenu(window, "optionlist"), mParent(parent)
mMenu(window, ""), mParent(parent)
{
auto font = Font::get(FONT_SIZE_MEDIUM);
ComponentListRow row;
for(auto it = mParent->mEntries.begin(); it != mParent->mEntries.end(); it++)
{
row.elements.clear();
row.addElement(std::make_shared<TextComponent>(mWindow, it->name, font, 0x777777FF), true);
mMenu.addRow(row);
OptionListData& e = *it;
if(mParent->mMultiSelect)
{
// add checkbox
auto checkbox = std::make_shared<ImageComponent>(mWindow);
checkbox->setImage(it->selected ? ":/checkbox_checked.png" : ":/checkbox_unchecked.png");
if(checkbox->getTextureSize().y() > (int)FONT_SIZE_MEDIUM) // downscale if necessary to match text
checkbox->setResize(0, (float)FONT_SIZE_MEDIUM);
row.addElement(checkbox, false);
// input handler
// update checkbox state & selected value
row.makeAcceptInputHandler([this, &e, checkbox]
{
e.selected = !e.selected;
checkbox->setImage(e.selected ? ":/checkbox_checked.png" : ":/checkbox_unchecked.png");
mParent->onSelectedChanged();
});
}else{
// input handler for non-multiselect
// update selected value and close
row.makeAcceptInputHandler([this, &e]
{
mParent->mEntries.at(mParent->getSelectedId()).selected = false;
e.selected = true;
mParent->onSelectedChanged();
delete this;
});
}
// also set cursor to this row if we're not multi-select and this row is selected
mMenu.addRow(row, (!mParent->mMultiSelect && it->selected));
}
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2, (Renderer::getScreenHeight() - mMenu.getSize().y()) / 2);
@ -62,16 +99,11 @@ private:
return GuiComponent::input(config, input);
}
virtual ~OptionListPopup()
{
// commit changes
}
};
public:
OptionListComponent(Window* window, bool multiSelect = false) : GuiComponent(window), mText(window), mMultiSelect(multiSelect)
OptionListComponent(Window* window, bool multiSelect = false) : GuiComponent(window), mMultiSelect(multiSelect),
mText(window), mLeftArrow(window), mRightArrow(window)
{
auto font = Font::get(FONT_SIZE_MEDIUM);
mText.setFont(font);
@ -79,12 +111,45 @@ public:
mText.setCentered(true);
addChild(&mText);
if(mMultiSelect)
{
mRightArrow.setImage(":/sq_bracket.png");
addChild(&mRightArrow);
}else{
mLeftArrow.setImage(":/arrow.png");
mLeftArrow.setFlipX(true);
addChild(&mLeftArrow);
mRightArrow.setImage(":/arrow.png");
addChild(&mRightArrow);
}
// handles positioning/resizing of text and arrows
setSize(Renderer::getScreenWidth() * 0.2f, (float)font->getHeight());
}
void onSizeChanged() override
{
mText.setSize(mSize);
// size
if(mLeftArrow.getTextureSize().y() > mSize.y())
mLeftArrow.setResize(0, mSize.y());
else
mLeftArrow.setResize(0, 0);
if(mRightArrow.getTextureSize().y() > mSize.y())
mRightArrow.setResize(0, mSize.y());
else
mRightArrow.setResize(0, 0);
if(mSize.x() < (mLeftArrow.getSize().x() + mRightArrow.getSize().x()))
LOG(LogWarning) << "OptionListComponent too narrow!";
mText.setSize(mSize.x() - mLeftArrow.getSize().x() - mRightArrow.getSize().x(), (float)mText.getFont()->getHeight());
// position
mLeftArrow.setPosition(0, (mSize.y() - mLeftArrow.getSize().y()) / 2);
mText.setPosition(mLeftArrow.getPosition().x() + mLeftArrow.getSize().x(), (mSize.y() - mText.getSize().y()) / 2);
mRightArrow.setPosition(mText.getPosition().x() + mText.getSize().x(), (mSize.y() - mRightArrow.getSize().y()) / 2);
}
bool input(InputConfig* config, Input input) override
@ -101,9 +166,26 @@ public:
if(config->isMappedTo("left", input))
{
// move selection to previous
unsigned int i = getSelectedId();
int next = (int)i - 1;
if(next < 0)
next += mEntries.size();
mEntries.at(i).selected = false;
mEntries.at(next).selected = true;
onSelectedChanged();
return true;
}else if(config->isMappedTo("right", input))
{
// move selection to next
unsigned int i = getSelectedId();
int next = (i + 1) % mEntries.size();
mEntries.at(i).selected = false;
mEntries.at(next).selected = true;
onSelectedChanged();
return true;
}
}
}
@ -142,6 +224,19 @@ public:
}
private:
unsigned int getSelectedId()
{
assert(mMultiSelect == false);
for(unsigned int i = 0; i < mEntries.size(); i++)
{
if(mEntries.at(i).selected)
return i;
}
LOG(LogWarning) << "OptionListComponent::getSelectedId() - no selected element found, defaulting to 0";
return 0;
}
void open()
{
mWindow->pushGui(new OptionListPopup(mWindow, this));
@ -171,6 +266,8 @@ private:
bool mMultiSelect;
TextComponent mText;
ImageComponent mLeftArrow;
ImageComponent mRightArrow;
std::vector<OptionListData> mEntries;
};