windows build
This commit is contained in:
parent
04d7285299
commit
fd284fa5dd
|
@ -10,10 +10,16 @@ This game is under development. Currently, the repository has been suspended sin
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
|
To build, you need to download the [Allegro static](https://github.com/liballeg/allegro5/releases) libraries and [static dependencies](https://github.com/liballeg/allegro_winpkg/releases). A pre-installed static [Enet](http://enet.bespin.org/) library is required to support the network ([package for MSYS2](https://packages.msys2.org/package/mingw-w64-x86_64-enet?repo=mingw64)).
|
||||||
|
|
||||||
|
Also, an installed g++ compiler and cmake build system are required for the assembly.
|
||||||
|
|
||||||
|
The working compilation of the project was carried out in [MSYS2](https://www.msys2.org/).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -B . -S ../game
|
cmake -G "Unix Makefiles" -B . -S ../game -D PATH_ALLEGRO_STATIC="C:\<path-to-allegro-static-libs>" -D PATH_DEPS_STATIC="C:\<path-to-deps-static-libs>"
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,72 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(spaceshooter)
|
project(spaceshooter)
|
||||||
|
|
||||||
|
set(STDCPP_LIB stdc++ -static)
|
||||||
|
|
||||||
|
set(PATH_ALLEGRO_STATIC "" CACHE PATH "Path to allegro static libs")
|
||||||
|
set(PATH_DEPS_STATIC "" CACHE PATH "Path to dependencies static libs")
|
||||||
|
|
||||||
include_directories("lib/" "network/" "objects/")
|
include_directories("lib/" "network/" "objects/")
|
||||||
|
|
||||||
|
# STATIC LIBRARY ALLEGRO 5
|
||||||
|
# https://github.com/liballeg/allegro5/releases
|
||||||
|
|
||||||
|
add_library(allegro STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro-static.a")
|
||||||
|
add_library(allegro_primitives STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_primitives PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_primitives-static.a")
|
||||||
|
add_library(allegro_dialog STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_dialog PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_dialog-static.a")
|
||||||
|
add_library(allegro_image STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_image PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_image-static.a")
|
||||||
|
add_library(allegro_font STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_font PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_font-static.a")
|
||||||
|
add_library(allegro_ttf STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_ttf PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_ttf-static.a")
|
||||||
|
add_library(allegro_audio STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_audio PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_audio-static.a")
|
||||||
|
add_library(allegro_acodec STATIC IMPORTED)
|
||||||
|
set_property(TARGET allegro_acodec PROPERTY IMPORTED_LOCATION "${PATH_ALLEGRO_STATIC}/liballegro_acodec-static.a")
|
||||||
|
|
||||||
|
# DEPENDENCIES
|
||||||
|
# https://github.com/liballeg/allegro_winpkg/releases
|
||||||
|
|
||||||
|
add_library(dumb STATIC IMPORTED)
|
||||||
|
set_property(TARGET dumb PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libdumb.a")
|
||||||
|
add_library(FLAC STATIC IMPORTED)
|
||||||
|
set_property(TARGET FLAC PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libFLAC.a")
|
||||||
|
add_library(freetype STATIC IMPORTED)
|
||||||
|
set_property(TARGET freetype PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libfreetype.a")
|
||||||
|
add_library(jpeg STATIC IMPORTED)
|
||||||
|
set_property(TARGET jpeg PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libjpeg.a")
|
||||||
|
add_library(ogg STATIC IMPORTED)
|
||||||
|
set_property(TARGET ogg PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libogg.a")
|
||||||
|
add_library(opus STATIC IMPORTED)
|
||||||
|
set_property(TARGET opus PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libopus.a")
|
||||||
|
add_library(opusfile STATIC IMPORTED)
|
||||||
|
set_property(TARGET opusfile PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libopusfile.a")
|
||||||
|
add_library(physfs STATIC IMPORTED)
|
||||||
|
set_property(TARGET physfs PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libphysfs.a")
|
||||||
|
add_library(png16 STATIC IMPORTED)
|
||||||
|
set_property(TARGET png16 PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libpng16.a")
|
||||||
|
add_library(theoradec STATIC IMPORTED)
|
||||||
|
set_property(TARGET theoradec PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libtheoradec.a")
|
||||||
|
add_library(vorbis STATIC IMPORTED)
|
||||||
|
set_property(TARGET vorbis PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libvorbis.a")
|
||||||
|
add_library(vorbisfile STATIC IMPORTED)
|
||||||
|
set_property(TARGET vorbisfile PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libvorbisfile.a")
|
||||||
|
add_library(webp STATIC IMPORTED)
|
||||||
|
set_property(TARGET webp PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libwebp.a")
|
||||||
|
add_library(webpdecoder STATIC IMPORTED)
|
||||||
|
set_property(TARGET webpdecoder PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libwebpdecoder.a")
|
||||||
|
add_library(webpdemux STATIC IMPORTED)
|
||||||
|
set_property(TARGET webpdemux PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libwebpdemux.a")
|
||||||
|
add_library(zlib STATIC IMPORTED)
|
||||||
|
set_property(TARGET zlib PROPERTY IMPORTED_LOCATION "${PATH_DEPS_STATIC}/libzlib.a")
|
||||||
|
|
||||||
|
# add_library(enet STATIC IMPORTED)
|
||||||
|
# set_property(TARGET enet PROPERTY IMPORTED_LOCATION "C:/msys64/mingw64/lib/libenet.a")
|
||||||
|
|
||||||
set(SRC_GAME
|
set(SRC_GAME
|
||||||
autors.c
|
autors.c
|
||||||
common.c
|
common.c
|
||||||
|
@ -34,26 +98,94 @@ set(SRC_NETWORK network/network.c)
|
||||||
|
|
||||||
set(SRC_OBJECTS objects/objects.c)
|
set(SRC_OBJECTS objects/objects.c)
|
||||||
|
|
||||||
find_library(ALLEGRO_LIB NAMES allegro)
|
set(ALLEGRO_LIB allegro)
|
||||||
find_library(ALLEGRO_PRIMITIVES_LIB NAMES allegro_primitives)
|
set(ALLEGRO_PRIMITIVES_LIB allegro_primitives)
|
||||||
find_library(ALLEGRO_DIALOG_LIB NAMES allegro_dialog)
|
set(ALLEGRO_DIALOG_LIB allegro_dialog)
|
||||||
find_library(ALLEGRO_IMAGE_LIB allegro_image)
|
set(ALLEGRO_IMAGE_LIB allegro_image)
|
||||||
find_library(ALLEGRO_FONT_LIB allegro_font)
|
set(ALLEGRO_FONT_LIB allegro_font)
|
||||||
find_library(ALLEGRO_TTF_LIB allegro_ttf)
|
set(ALLEGRO_TTF_LIB allegro_ttf)
|
||||||
find_library(ALLEGRO_AUDIO_LIB allegro_audio)
|
set(ALLEGRO_AUDIO_LIB allegro_audio)
|
||||||
find_library(ALLEGRO_ACODEC_LIB allegro_acodec)
|
set(ALLEGRO_ACODEC_LIB allegro_acodec)
|
||||||
find_library(ENET_LIB enet)
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SRC_OBJECTS} ${SRC_LIB} ${SRC_NETWORK} ${SRC_GAME})
|
# https://packages.msys2.org/package/mingw-w64-x86_64-enet?repo=mingw64
|
||||||
|
set(ENET_LIB enet)
|
||||||
|
|
||||||
|
find_library(WINMM_LIB winmm)
|
||||||
|
find_library(OPENGL32_LIB opengl32)
|
||||||
|
find_library(GDI32_LIB gdi32)
|
||||||
|
find_library(OLE32_LIB ole32)
|
||||||
|
find_library(SHLWAPI_LIB shlwapi)
|
||||||
|
find_library(DSOUND_LIB dsound)
|
||||||
|
find_library(WS2_32_LIB ws2_32)
|
||||||
|
|
||||||
|
set(FLAC_LIB FLAC)
|
||||||
|
set(OGG_LIB ogg)
|
||||||
|
set(VORBIS_LIB vorbis)
|
||||||
|
set(OPUS_LIB opus)
|
||||||
|
set(PNG16_LIB png16)
|
||||||
|
set(FREETYPE_LIB freetype)
|
||||||
|
set(JPEG_LIB jpeg)
|
||||||
|
set(WEBP_LIB webp)
|
||||||
|
set(DUMB_LIB dumb)
|
||||||
|
set(VORBISFILE_LIB vorbisfile)
|
||||||
|
set(OPUSFILE_LIB opusfile)
|
||||||
|
set(Z_LIB zlib)
|
||||||
|
|
||||||
|
set(PHYSFS_LIB physfs)
|
||||||
|
|
||||||
|
find_library(GDIPLUS_32_LIB gdiplus)
|
||||||
|
find_library(UUID_LIB uuid)
|
||||||
|
find_library(KERNEL32_LIB kernel32)
|
||||||
|
find_library(PSAPI_32_LIB psapi)
|
||||||
|
find_library(GLU32_32_LIB glu32)
|
||||||
|
find_library(USER32_LIB user32)
|
||||||
|
find_library(COMDLG32_LIB Comdlg32)
|
||||||
|
find_library(SHELL32_LIB shell32)
|
||||||
|
find_library(ADVAPI32_LIB advapi32)
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} WIN32 ${SRC_OBJECTS} ${SRC_LIB} ${SRC_NETWORK} ${SRC_GAME})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
${ALLEGRO_LIB}
|
|
||||||
${ALLEGRO_PRIMITIVES_LIB}
|
${ALLEGRO_PRIMITIVES_LIB}
|
||||||
${ALLEGRO_DIALOG_LIB}
|
${ALLEGRO_DIALOG_LIB}
|
||||||
${ALLEGRO_IMAGE_LIB}
|
${ALLEGRO_IMAGE_LIB}
|
||||||
${ALLEGRO_COLOR_LIB}
|
|
||||||
${ALLEGRO_FONT_LIB}
|
${ALLEGRO_FONT_LIB}
|
||||||
${ALLEGRO_TTF_LIB}
|
${ALLEGRO_TTF_LIB}
|
||||||
${ALLEGRO_AUDIO_LIB}
|
${ALLEGRO_AUDIO_LIB}
|
||||||
${ALLEGRO_ACODEC_LIB}
|
${ALLEGRO_ACODEC_LIB}
|
||||||
${ENET_LIB})
|
${ALLEGRO_LIB}
|
||||||
|
|
||||||
|
${ENET_LIB}
|
||||||
|
|
||||||
|
${JPEG_LIB}
|
||||||
|
${DUMB_LIB}
|
||||||
|
${WEBP_LIB}
|
||||||
|
${FLAC_LIB}
|
||||||
|
${VORBISFILE_LIB}
|
||||||
|
${VORBIS_LIB}
|
||||||
|
${OGG_LIB}
|
||||||
|
${FREETYPE_LIB}
|
||||||
|
${PNG16_LIB}
|
||||||
|
${DSOUND_LIB}
|
||||||
|
${WINMM_LIB}
|
||||||
|
${OPENGL32_LIB}
|
||||||
|
${GDI32_LIB}
|
||||||
|
${OLE32_LIB}
|
||||||
|
${SHLWAPI_LIB}
|
||||||
|
${STDCPP_LIB}
|
||||||
|
${Z_LIB}
|
||||||
|
${OPUSFILE_LIB}
|
||||||
|
${OPUS_LIB}
|
||||||
|
${WS2_32_LIB}
|
||||||
|
|
||||||
|
# ${PHYSFS_LIB}
|
||||||
|
# ${GDIPLUS_32_LIB}
|
||||||
|
# ${UUID_LIB}
|
||||||
|
# ${KERNEL32_LIB}
|
||||||
|
# ${PSAPI_32_LIB}
|
||||||
|
# ${GLU32_32_LIB}
|
||||||
|
# ${USER32_LIB}
|
||||||
|
# ${COMDLG32_LIB}
|
||||||
|
# ${SHELL32_LIB}
|
||||||
|
# ${ADVAPI32_LIB}
|
||||||
|
)
|
||||||
|
|
|
@ -106,13 +106,13 @@ void autors_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void autors_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void autors_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[AUTORS]->button_size > key_button)
|
if(data->pairing.intface[AUTORS]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[AUTORS]->button[key_button],
|
data->pairing.intface[AUTORS]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 6)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 6)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -124,17 +124,17 @@ void autors_init_button(CLIENT_DATA* data, int key_button, int key_font, const c
|
||||||
|
|
||||||
static void autors_push_button(CLIENT_DATA* data)
|
static void autors_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font && interface->button[i]->selected)
|
if(intface->button[i]->al_font && intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case BUTTON_AUTORS_OUT:
|
case BUTTON_AUTORS_OUT:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, MENU);
|
cl_change_state(data, MENU);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
146
game/common.c
146
game/common.c
|
@ -17,19 +17,19 @@
|
||||||
|
|
||||||
void cl_init_interfaces(CLIENT_PAIRING* pairing)
|
void cl_init_interfaces(CLIENT_PAIRING* pairing)
|
||||||
{
|
{
|
||||||
pairing->interface[MENU] = cl_create_interface(2, 5, 0);
|
pairing->intface[MENU] = cl_create_interface(2, 5, 0);
|
||||||
pairing->interface[SINGLE] = cl_create_interface(3, 0, 0);
|
pairing->intface[SINGLE] = cl_create_interface(3, 0, 0);
|
||||||
pairing->interface[NETWORKMODE] = cl_create_interface(0, 3, 0);
|
pairing->intface[NETWORKMODE] = cl_create_interface(0, 3, 0);
|
||||||
pairing->interface[NETWORKCREATE] = cl_create_interface(0, 2, 2);
|
pairing->intface[NETWORKCREATE] = cl_create_interface(0, 2, 2);
|
||||||
pairing->interface[NETWORKJOIN] = cl_create_interface(0, 2, 1);
|
pairing->intface[NETWORKJOIN] = cl_create_interface(0, 2, 1);
|
||||||
pairing->interface[NETWORKLIST] = cl_create_interface(0, 1, 0);
|
pairing->intface[NETWORKLIST] = cl_create_interface(0, 1, 0);
|
||||||
pairing->interface[NETWORKPARTY] = cl_create_interface(0, 4, 0);
|
pairing->intface[NETWORKPARTY] = cl_create_interface(0, 4, 0);
|
||||||
pairing->interface[NETWORKGAME] = cl_create_interface(3, 0, 0);
|
pairing->intface[NETWORKGAME] = cl_create_interface(3, 0, 0);
|
||||||
pairing->interface[NETWORKOUT] = cl_create_interface(0, 2, 0);
|
pairing->intface[NETWORKOUT] = cl_create_interface(0, 2, 0);
|
||||||
pairing->interface[SETTINGS] = cl_create_interface(0, 0, 0);
|
pairing->intface[SETTINGS] = cl_create_interface(0, 0, 0);
|
||||||
pairing->interface[AUTORS] = cl_create_interface(0, 1, 0); // 0 background size (background copies)
|
pairing->intface[AUTORS] = cl_create_interface(0, 1, 0); // 0 background size (background copies)
|
||||||
pairing->interface[PAUSE] = cl_create_interface(0, 2, 0); // 0 background size (background copies)
|
pairing->intface[PAUSE] = cl_create_interface(0, 2, 0); // 0 background size (background copies)
|
||||||
pairing->interface[GAMEOVER] = cl_create_interface(0, 1, 0); // 0 background size (background copies)
|
pairing->intface[GAMEOVER] = cl_create_interface(0, 1, 0); // 0 background size (background copies)
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl_load_media(CLIENT_MEDIA* media)
|
void cl_load_media(CLIENT_MEDIA* media)
|
||||||
|
@ -260,21 +260,21 @@ void cl_play_sound(CLIENT_DATA* data, int key_sample)
|
||||||
|
|
||||||
static void cl_init_background(CLIENT_DATA* data, int key_state, int key_bitmap, float x, float y, float vel_x, float vel_y, int dir_x, int dir_y)
|
static void cl_init_background(CLIENT_DATA* data, int key_state, int key_bitmap, float x, float y, float vel_x, float vel_y, int dir_x, int dir_y)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[key_state]->background_size > key_bitmap)
|
if(data->pairing.intface[key_state]->background_size > key_bitmap)
|
||||||
cl_add_interface_background(
|
cl_add_interface_background(
|
||||||
data->pairing.interface[key_state]->background[key_bitmap],
|
data->pairing.intface[key_state]->background[key_bitmap],
|
||||||
data->media.bitmaps[key_bitmap],
|
data->media.bitmaps[key_bitmap],
|
||||||
dir_x, dir_y, vel_x, vel_y, x, y);
|
dir_x, dir_y, vel_x, vel_y, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cl_copy_background(CLIENT_DATA* data, int dir_key_state, int src_key_state)
|
static void cl_copy_background(CLIENT_DATA* data, int dir_key_state, int src_key_state)
|
||||||
{
|
{
|
||||||
data->pairing.interface[dir_key_state]->background = data->pairing.interface[src_key_state]->background;
|
data->pairing.intface[dir_key_state]->background = data->pairing.intface[src_key_state]->background;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cl_draw_background(CLIENT_DATA* data, int key_bitmap)
|
void cl_draw_background(CLIENT_DATA* data, int key_bitmap)
|
||||||
{
|
{
|
||||||
CLIENT_BACKGROUND_PAGE* bg = data->pairing.interface[data->state]->background[key_bitmap];
|
CLIENT_BACKGROUND_PAGE* bg = data->pairing.intface[data->state]->background[key_bitmap];
|
||||||
|
|
||||||
al_draw_bitmap(bg->bitmap->al_bitmap, bg->x, bg->y, 0);
|
al_draw_bitmap(bg->bitmap->al_bitmap, bg->x, bg->y, 0);
|
||||||
al_draw_bitmap(bg->bitmap->al_bitmap, bg->x + bg->bitmap->width, bg->y, 0);
|
al_draw_bitmap(bg->bitmap->al_bitmap, bg->x + bg->bitmap->width, bg->y, 0);
|
||||||
|
@ -285,7 +285,7 @@ void cl_draw_background(CLIENT_DATA* data, int key_bitmap)
|
||||||
|
|
||||||
void cl_update_background(CLIENT_DATA* data, int key_bitmap)
|
void cl_update_background(CLIENT_DATA* data, int key_bitmap)
|
||||||
{
|
{
|
||||||
CLIENT_BACKGROUND_PAGE* bg = data->pairing.interface[data->state]->background[key_bitmap];
|
CLIENT_BACKGROUND_PAGE* bg = data->pairing.intface[data->state]->background[key_bitmap];
|
||||||
|
|
||||||
bg->x += bg->vel_x * bg->dir_x;
|
bg->x += bg->vel_x * bg->dir_x;
|
||||||
if(bg->x + bg->bitmap->width < 0)
|
if(bg->x + bg->bitmap->width < 0)
|
||||||
|
@ -301,7 +301,7 @@ static void cl_init_header(CLIENT_DATA* data, int key_state, int key_font, const
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_header(
|
cl_add_interface_header(
|
||||||
&data->pairing.interface[key_state]->header,
|
&data->pairing.intface[key_state]->header,
|
||||||
data->media.fonts[key_font]->al_font,
|
data->media.fonts[key_font]->al_font,
|
||||||
data->screen.width / 2,
|
data->screen.width / 2,
|
||||||
block_size - data->media.fonts[key_font]->size / 2,
|
block_size - data->media.fonts[key_font]->size / 2,
|
||||||
|
@ -310,7 +310,7 @@ static void cl_init_header(CLIENT_DATA* data, int key_state, int key_font, const
|
||||||
|
|
||||||
void cl_draw_header(CLIENT_DATA* data)
|
void cl_draw_header(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_HEADER header = data->pairing.interface[data->state]->header;
|
CLIENT_HEADER header = data->pairing.intface[data->state]->header;
|
||||||
|
|
||||||
al_draw_text(header.al_font, al_map_rgb(255, 255, 255), header.x, header.y, ALLEGRO_ALIGN_CENTRE, header.text);
|
al_draw_text(header.al_font, al_map_rgb(255, 255, 255), header.x, header.y, ALLEGRO_ALIGN_CENTRE, header.text);
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ void cl_draw_header(CLIENT_DATA* data)
|
||||||
// use with mouse event
|
// use with mouse event
|
||||||
void cl_update_button(CLIENT_DATA* data)
|
void cl_update_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
int mx, my;
|
int mx, my;
|
||||||
|
|
||||||
if(data->screen.fullscreen)
|
if(data->screen.fullscreen)
|
||||||
|
@ -335,9 +335,9 @@ void cl_update_button(CLIENT_DATA* data)
|
||||||
my = data->event.current.mouse.y;
|
my = data->event.current.mouse.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
{
|
{
|
||||||
CLIENT_BUTTON* btn = interface->button[i];
|
CLIENT_BUTTON* btn = intface->button[i];
|
||||||
|
|
||||||
if(!btn->active) continue;
|
if(!btn->active) continue;
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ void cl_update_button(CLIENT_DATA* data)
|
||||||
cl_play_sound(data, SAMPLE_BUTTON);
|
cl_play_sound(data, SAMPLE_BUTTON);
|
||||||
|
|
||||||
btn->selected = true;
|
btn->selected = true;
|
||||||
interface->selected = SELECTED_BUTTON;
|
intface->selected = SELECTED_BUTTON;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
btn->selected = false;
|
btn->selected = false;
|
||||||
|
@ -356,15 +356,15 @@ void cl_update_button(CLIENT_DATA* data)
|
||||||
// use with key
|
// use with key
|
||||||
void cl_select_button(CLIENT_DATA* data)
|
void cl_select_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
bool is_selected = false;
|
bool is_selected = false;
|
||||||
|
|
||||||
if(interface->selected == SELECTED_BUTTON)
|
if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
int count_active_button = 0;
|
int count_active_button = 0;
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->active)
|
if(intface->button[i]->active)
|
||||||
count_active_button++;
|
count_active_button++;
|
||||||
|
|
||||||
if(count_active_button)
|
if(count_active_button)
|
||||||
|
@ -372,9 +372,9 @@ void cl_select_button(CLIENT_DATA* data)
|
||||||
CLIENT_BUTTON* button[count_active_button];
|
CLIENT_BUTTON* button[count_active_button];
|
||||||
int iterator = 0;
|
int iterator = 0;
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->active)
|
if(intface->button[i]->active)
|
||||||
button[iterator++] = interface->button[i];
|
button[iterator++] = intface->button[i];
|
||||||
|
|
||||||
for(int i = 0; i < count_active_button; i++)
|
for(int i = 0; i < count_active_button; i++)
|
||||||
if(button[i]->selected)
|
if(button[i]->selected)
|
||||||
|
@ -411,30 +411,30 @@ void cl_select_button(CLIENT_DATA* data)
|
||||||
cl_play_sound(data, SAMPLE_BUTTON);
|
cl_play_sound(data, SAMPLE_BUTTON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_FIELD)
|
else if(intface->selected == SELECTED_FIELD)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
if(interface->field[i]->selected)
|
if(intface->field[i]->selected)
|
||||||
{
|
{
|
||||||
interface->field[i]->enter = false;
|
intface->field[i]->enter = false;
|
||||||
|
|
||||||
if(data->keys[UP] && !data->keys[DOWN])
|
if(data->keys[UP] && !data->keys[DOWN])
|
||||||
{
|
{
|
||||||
interface->field[i]->selected = false;
|
intface->field[i]->selected = false;
|
||||||
|
|
||||||
if(i != 0)
|
if(i != 0)
|
||||||
interface->field[i - 1]->selected = true;
|
intface->field[i - 1]->selected = true;
|
||||||
else
|
else
|
||||||
interface->field[interface->field_size - 1]->selected = true;
|
intface->field[intface->field_size - 1]->selected = true;
|
||||||
}
|
}
|
||||||
else if(data->keys[DOWN] && !data->keys[UP])
|
else if(data->keys[DOWN] && !data->keys[UP])
|
||||||
{
|
{
|
||||||
interface->field[i]->selected = false;
|
intface->field[i]->selected = false;
|
||||||
|
|
||||||
if(i == interface->field_size - 1)
|
if(i == intface->field_size - 1)
|
||||||
interface->field[0]->selected = true;
|
intface->field[0]->selected = true;
|
||||||
else
|
else
|
||||||
interface->field[i + 1]->selected = true;
|
intface->field[i + 1]->selected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_selected = true;
|
is_selected = true;
|
||||||
|
@ -443,18 +443,18 @@ void cl_select_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
if(!is_selected)
|
if(!is_selected)
|
||||||
if(data->keys[UP] && !data->keys[DOWN])
|
if(data->keys[UP] && !data->keys[DOWN])
|
||||||
interface->field[interface->field_size - 1]->selected = true;
|
intface->field[intface->field_size - 1]->selected = true;
|
||||||
else if(data->keys[DOWN] && !data->keys[UP])
|
else if(data->keys[DOWN] && !data->keys[UP])
|
||||||
interface->field[0]->selected = true;
|
intface->field[0]->selected = true;
|
||||||
|
|
||||||
cl_play_sound(data, SAMPLE_BUTTON);
|
cl_play_sound(data, SAMPLE_BUTTON);
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_LIST)
|
else if(intface->selected == SELECTED_LIST)
|
||||||
{
|
{
|
||||||
int count_active_item = 0;
|
int count_active_item = 0;
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
if(interface->list.item[i].active)
|
if(intface->list.item[i].active)
|
||||||
count_active_item++;
|
count_active_item++;
|
||||||
|
|
||||||
if(count_active_item)
|
if(count_active_item)
|
||||||
|
@ -463,8 +463,8 @@ void cl_select_button(CLIENT_DATA* data)
|
||||||
int iterator = 0;
|
int iterator = 0;
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
if(interface->list.item[i].active)
|
if(intface->list.item[i].active)
|
||||||
item[iterator++] = &interface->list.item[i];
|
item[iterator++] = &intface->list.item[i];
|
||||||
|
|
||||||
for(int i = 0; i < count_active_item; i++)
|
for(int i = 0; i < count_active_item; i++)
|
||||||
if(item[i]->selected)
|
if(item[i]->selected)
|
||||||
|
@ -505,12 +505,12 @@ void cl_select_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
void cl_draw_button(CLIENT_DATA* data)
|
void cl_draw_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font)
|
if(intface->button[i]->al_font)
|
||||||
{
|
{
|
||||||
CLIENT_BUTTON* btn = interface->button[i];
|
CLIENT_BUTTON* btn = intface->button[i];
|
||||||
ALLEGRO_COLOR clr;
|
ALLEGRO_COLOR clr;
|
||||||
|
|
||||||
btn->active = true;
|
btn->active = true;
|
||||||
|
@ -531,11 +531,11 @@ void cl_draw_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
void cl_draw_field(CLIENT_DATA* data)
|
void cl_draw_field(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
{
|
{
|
||||||
CLIENT_FIELD* field = interface->field[i];
|
CLIENT_FIELD* field = intface->field[i];
|
||||||
ALLEGRO_COLOR clr;
|
ALLEGRO_COLOR clr;
|
||||||
|
|
||||||
if(field->selected)
|
if(field->selected)
|
||||||
|
@ -554,7 +554,7 @@ void cl_draw_field(CLIENT_DATA* data)
|
||||||
|
|
||||||
void cl_update_field(CLIENT_DATA* data)
|
void cl_update_field(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
int mx, my;
|
int mx, my;
|
||||||
|
|
||||||
if(data->screen.fullscreen)
|
if(data->screen.fullscreen)
|
||||||
|
@ -568,9 +568,9 @@ void cl_update_field(CLIENT_DATA* data)
|
||||||
my = data->event.current.mouse.y;
|
my = data->event.current.mouse.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
{
|
{
|
||||||
CLIENT_FIELD* field = interface->field[i];
|
CLIENT_FIELD* field = intface->field[i];
|
||||||
|
|
||||||
if(field->f_sx < mx && field->f_dx > mx && field->f_sy < my && field->f_dy > my)
|
if(field->f_sx < mx && field->f_dx > mx && field->f_sy < my && field->f_dy > my)
|
||||||
{
|
{
|
||||||
|
@ -578,7 +578,7 @@ void cl_update_field(CLIENT_DATA* data)
|
||||||
cl_play_sound(data, SAMPLE_BUTTON);
|
cl_play_sound(data, SAMPLE_BUTTON);
|
||||||
|
|
||||||
field->selected = true;
|
field->selected = true;
|
||||||
interface->selected = SELECTED_FIELD;
|
intface->selected = SELECTED_FIELD;
|
||||||
}
|
}
|
||||||
else if(field->enter)
|
else if(field->enter)
|
||||||
field->selected = true;
|
field->selected = true;
|
||||||
|
@ -589,7 +589,7 @@ void cl_update_field(CLIENT_DATA* data)
|
||||||
|
|
||||||
void cl_enter_field(CLIENT_DATA* data)
|
void cl_enter_field(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
int mx, my;
|
int mx, my;
|
||||||
|
|
||||||
if(data->screen.fullscreen)
|
if(data->screen.fullscreen)
|
||||||
|
@ -603,9 +603,9 @@ void cl_enter_field(CLIENT_DATA* data)
|
||||||
my = data->event.current.mouse.y;
|
my = data->event.current.mouse.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
{
|
{
|
||||||
CLIENT_FIELD* field = interface->field[i];
|
CLIENT_FIELD* field = intface->field[i];
|
||||||
|
|
||||||
if(field->f_sx < mx && field->f_dx > mx && field->f_sy < my && field->f_dy > my)
|
if(field->f_sx < mx && field->f_dx > mx && field->f_sy < my && field->f_dy > my)
|
||||||
field->enter = true;
|
field->enter = true;
|
||||||
|
@ -709,11 +709,11 @@ void cl_print_field(CLIENT_DATA* data)
|
||||||
|
|
||||||
if(symbol != '\0')
|
if(symbol != '\0')
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
{
|
{
|
||||||
CLIENT_FIELD* field = interface->field[i];
|
CLIENT_FIELD* field = intface->field[i];
|
||||||
|
|
||||||
if(field->enter && field->char_number < 18)
|
if(field->enter && field->char_number < 18)
|
||||||
{
|
{
|
||||||
|
@ -726,11 +726,11 @@ void cl_print_field(CLIENT_DATA* data)
|
||||||
}
|
}
|
||||||
else if(backspace)
|
else if(backspace)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
{
|
{
|
||||||
CLIENT_FIELD* field = interface->field[i];
|
CLIENT_FIELD* field = intface->field[i];
|
||||||
|
|
||||||
if(field->enter && field->char_number > 0)
|
if(field->enter && field->char_number > 0)
|
||||||
{
|
{
|
||||||
|
@ -748,7 +748,7 @@ void cl_print_field(CLIENT_DATA* data)
|
||||||
|
|
||||||
void cl_draw_list(CLIENT_DATA* data)
|
void cl_draw_list(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &data->pairing.interface[data->state]->list;
|
CLIENT_LIST* list = &data->pairing.intface[data->state]->list;
|
||||||
|
|
||||||
// if(btn->selected)
|
// if(btn->selected)
|
||||||
// clr = al_map_rgba_f(0.4, 0.4, 0.0, 0.2);
|
// clr = al_map_rgba_f(0.4, 0.4, 0.0, 0.2);
|
||||||
|
@ -760,7 +760,7 @@ void cl_draw_list(CLIENT_DATA* data)
|
||||||
|
|
||||||
void cl_update_list(CLIENT_DATA* data)
|
void cl_update_list(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &data->pairing.interface[data->state]->list;
|
CLIENT_LIST* list = &data->pairing.intface[data->state]->list;
|
||||||
int mx, my;
|
int mx, my;
|
||||||
|
|
||||||
if(data->screen.fullscreen)
|
if(data->screen.fullscreen)
|
||||||
|
@ -783,7 +783,7 @@ void cl_update_list(CLIENT_DATA* data)
|
||||||
if(item->sx_item < mx && item->dx_item > mx && item->sy_item < my && item->dy_item > my)
|
if(item->sx_item < mx && item->dx_item > mx && item->sy_item < my && item->dy_item > my)
|
||||||
{
|
{
|
||||||
item->selected = true;
|
item->selected = true;
|
||||||
data->pairing.interface[data->state]->selected = SELECTED_LIST;
|
data->pairing.intface[data->state]->selected = SELECTED_LIST;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
item->selected = false;
|
item->selected = false;
|
||||||
|
@ -798,7 +798,7 @@ void cl_send_message_create(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_MESSAGE_NONE message;
|
CLIENT_MESSAGE_NONE message;
|
||||||
|
|
||||||
CLIENT_FIELD** field = data->pairing.interface[data->state]->field;
|
CLIENT_FIELD** field = data->pairing.intface[data->state]->field;
|
||||||
|
|
||||||
message.display_height = data->screen.display_height;
|
message.display_height = data->screen.display_height;
|
||||||
message.display_width = data->screen.display_width;
|
message.display_width = data->screen.display_width;
|
||||||
|
@ -818,7 +818,7 @@ void cl_send_message_join(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_MESSAGE_NONE message;
|
CLIENT_MESSAGE_NONE message;
|
||||||
|
|
||||||
CLIENT_FIELD** field = data->pairing.interface[data->state]->field;
|
CLIENT_FIELD** field = data->pairing.intface[data->state]->field;
|
||||||
|
|
||||||
message.display_height = data->screen.display_height;
|
message.display_height = data->screen.display_height;
|
||||||
message.display_width = data->screen.display_width;
|
message.display_width = data->screen.display_width;
|
||||||
|
|
|
@ -87,13 +87,13 @@ void gameover_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void gameover_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void gameover_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[GAMEOVER]->button_size > key_button)
|
if(data->pairing.intface[GAMEOVER]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[GAMEOVER]->button[key_button],
|
data->pairing.intface[GAMEOVER]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 6)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 6)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -105,17 +105,17 @@ void gameover_init_button(CLIENT_DATA* data, int key_button, int key_font, const
|
||||||
|
|
||||||
static void gameover_push_button(CLIENT_DATA* data)
|
static void gameover_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font && interface->button[i]->selected)
|
if(intface->button[i]->al_font && intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case BUTTON_GAMEOVER_OUT:
|
case BUTTON_GAMEOVER_OUT:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, MENU);
|
cl_change_state(data, MENU);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,14 +13,14 @@ CLIENT_PAIRING* cl_create_pairing(CLIENT_PAIRING* pairing, int interface_size)
|
||||||
|
|
||||||
if(interface_size)
|
if(interface_size)
|
||||||
{
|
{
|
||||||
pairing->interface = (CLIENT_INTERFACE**)malloc(sizeof(CLIENT_INTERFACE*) * interface_size);
|
pairing->intface = (CLIENT_INTERFACE**)malloc(sizeof(CLIENT_INTERFACE*) * interface_size);
|
||||||
show_message_error(pairing->interface, "Failed to allocate space for CLIENT_INTERFACE collection");
|
show_message_error(pairing->intface, "Failed to allocate space for CLIENT_INTERFACE collection");
|
||||||
|
|
||||||
for(int i = 0; i < interface_size; i++)
|
for(int i = 0; i < interface_size; i++)
|
||||||
pairing->interface[i] = NULL;
|
pairing->intface[i] = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pairing->interface = NULL;
|
pairing->intface = NULL;
|
||||||
|
|
||||||
return pairing;
|
return pairing;
|
||||||
}
|
}
|
||||||
|
@ -130,13 +130,13 @@ void cl_destroy_pairing(CLIENT_PAIRING* pairing)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < pairing->interface_size; i++)
|
for(int i = 0; i < pairing->interface_size; i++)
|
||||||
{
|
{
|
||||||
if(pairing->interface[i])
|
if(pairing->intface[i])
|
||||||
{
|
{
|
||||||
cl_destroy_interface(pairing->interface[i]);
|
cl_destroy_interface(pairing->intface[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pairing->interface);
|
free(pairing->intface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cl_destroy_interface(CLIENT_INTERFACE* interface)
|
static void cl_destroy_interface(CLIENT_INTERFACE* interface)
|
||||||
|
|
|
@ -114,7 +114,7 @@ typedef struct cl_interface
|
||||||
|
|
||||||
typedef struct cl_pairing
|
typedef struct cl_pairing
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE** interface;
|
CLIENT_INTERFACE** intface;
|
||||||
int interface_size;
|
int interface_size;
|
||||||
} CLIENT_PAIRING;
|
} CLIENT_PAIRING;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ int main(int argc, char** argv)
|
||||||
.sound_size = 2,
|
.sound_size = 2,
|
||||||
// network
|
// network
|
||||||
.enet_port = 9234,
|
.enet_port = 9234,
|
||||||
.enet_host = "127.0.0.1",
|
.enet_host = "10.100.0.11",
|
||||||
// settings
|
// settings
|
||||||
.effects_gain = 0.1,
|
.effects_gain = 0.1,
|
||||||
.music_gain = 0.1
|
.music_gain = 0.1
|
||||||
|
|
16
game/menu.c
16
game/menu.c
|
@ -106,13 +106,13 @@ void menu_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void menu_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void menu_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[MENU]->button_size > key_button)
|
if(data->pairing.intface[MENU]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[MENU]->button[key_button],
|
data->pairing.intface[MENU]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 2)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 2)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -124,10 +124,10 @@ void menu_init_button(CLIENT_DATA* data, int key_button, int key_font, const cha
|
||||||
|
|
||||||
static void menu_push_button(CLIENT_DATA* data)
|
static void menu_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->selected)
|
if(intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
|
@ -135,14 +135,14 @@ static void menu_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
case BUTTON_MENU_SINGLE:
|
case BUTTON_MENU_SINGLE:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
al_hide_mouse_cursor(data->screen.display);
|
al_hide_mouse_cursor(data->screen.display);
|
||||||
cl_change_state(data, SINGLE);
|
cl_change_state(data, SINGLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BUTTON_MENU_NETWORK:
|
case BUTTON_MENU_NETWORK:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKMODE);
|
cl_change_state(data, NETWORKMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ static void menu_push_button(CLIENT_DATA* data)
|
||||||
break;
|
break;
|
||||||
case BUTTON_MENU_AUTORS:
|
case BUTTON_MENU_AUTORS:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, AUTORS);
|
cl_change_state(data, AUTORS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,13 +118,13 @@ void networkcreate_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networkcreate_init_field(CLIENT_DATA* data, int key_field, int key_font, const char* description)
|
void networkcreate_init_field(CLIENT_DATA* data, int key_field, int key_font, const char* description)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKCREATE]->field_size > key_field)
|
if(data->pairing.intface[NETWORKCREATE]->field_size > key_field)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_field(
|
cl_add_interface_field(
|
||||||
data->pairing.interface[NETWORKCREATE]->field[key_field],
|
data->pairing.intface[NETWORKCREATE]->field[key_field],
|
||||||
font->al_font, font->size, description,
|
font->al_font, font->size, description,
|
||||||
(data->screen.width / 2) - al_get_text_width(font->al_font, description),
|
(data->screen.width / 2) - al_get_text_width(font->al_font, description),
|
||||||
(block_size * (key_field + 3) - font->size / 2),
|
(block_size * (key_field + 3) - font->size / 2),
|
||||||
|
@ -142,13 +142,13 @@ void networkcreate_init_field(CLIENT_DATA* data, int key_field, int key_font, co
|
||||||
|
|
||||||
void networkcreate_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void networkcreate_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKCREATE]->button_size > key_button)
|
if(data->pairing.intface[NETWORKCREATE]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[NETWORKCREATE]->button[key_button],
|
data->pairing.intface[NETWORKCREATE]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 5)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 5)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -160,40 +160,40 @@ void networkcreate_init_button(CLIENT_DATA* data, int key_button, int key_font,
|
||||||
|
|
||||||
static void networkcreate_push_button(CLIENT_DATA* data)
|
static void networkcreate_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
if(interface->selected == SELECTED_BUTTON)
|
if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font && interface->button[i]->selected)
|
if(intface->button[i]->al_font && intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case BUTTON_NETWORKCREATE_CREATE:
|
case BUTTON_NETWORKCREATE_CREATE:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
if(networkcreate_check_field(data))
|
if(networkcreate_check_field(data))
|
||||||
cl_change_state(data, NETWORKPARTY);
|
cl_change_state(data, NETWORKPARTY);
|
||||||
break;
|
break;
|
||||||
case BUTTON_NETWORKCREATE_OUT:
|
case BUTTON_NETWORKCREATE_OUT:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKMODE);
|
cl_change_state(data, NETWORKMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_FIELD)
|
else if(intface->selected == SELECTED_FIELD)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
if(interface->field[i]->selected)
|
if(intface->field[i]->selected)
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case FIELD_NETWORKCREATE_NICKNAME:
|
case FIELD_NETWORKCREATE_NICKNAME:
|
||||||
interface->field[i]->enter = true;
|
intface->field[i]->enter = true;
|
||||||
break;
|
break;
|
||||||
case FIELD_NETWORKCREATE_GAMENAME:
|
case FIELD_NETWORKCREATE_GAMENAME:
|
||||||
interface->field[i]->enter = true;
|
intface->field[i]->enter = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,17 +201,17 @@ static void networkcreate_push_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
static void networkcreate_change_selected(CLIENT_DATA* data)
|
static void networkcreate_change_selected(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
cl_change_selected(data->pairing.interface[data->state]);
|
cl_change_selected(data->pairing.intface[data->state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool networkcreate_check_field(CLIENT_DATA* data)
|
static bool networkcreate_check_field(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
int field_size = interface->field_size;
|
int field_size = intface->field_size;
|
||||||
int field_filled_size = 0;
|
int field_filled_size = 0;
|
||||||
|
|
||||||
for(int i = 0; i < field_size; i++)
|
for(int i = 0; i < field_size; i++)
|
||||||
if(interface->field[i]->char_number > 0)
|
if(intface->field[i]->char_number > 0)
|
||||||
field_filled_size++;
|
field_filled_size++;
|
||||||
|
|
||||||
return field_size == field_filled_size;
|
return field_size == field_filled_size;
|
||||||
|
|
|
@ -115,13 +115,13 @@ void networkjoin_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networkjoin_init_field(CLIENT_DATA* data, int key_field, int key_font, const char* description)
|
void networkjoin_init_field(CLIENT_DATA* data, int key_field, int key_font, const char* description)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKJOIN]->field_size > key_field)
|
if(data->pairing.intface[NETWORKJOIN]->field_size > key_field)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_field(
|
cl_add_interface_field(
|
||||||
data->pairing.interface[NETWORKJOIN]->field[key_field],
|
data->pairing.intface[NETWORKJOIN]->field[key_field],
|
||||||
font->al_font, font->size, description,
|
font->al_font, font->size, description,
|
||||||
(data->screen.width / 2) - al_get_text_width(font->al_font, description),
|
(data->screen.width / 2) - al_get_text_width(font->al_font, description),
|
||||||
(block_size * (key_field + 3) - font->size / 2),
|
(block_size * (key_field + 3) - font->size / 2),
|
||||||
|
@ -139,13 +139,13 @@ void networkjoin_init_field(CLIENT_DATA* data, int key_field, int key_font, cons
|
||||||
|
|
||||||
void networkjoin_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void networkjoin_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKJOIN]->button_size > key_button)
|
if(data->pairing.intface[NETWORKJOIN]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[NETWORKJOIN]->button[key_button],
|
data->pairing.intface[NETWORKJOIN]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 5)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 5)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -157,37 +157,37 @@ void networkjoin_init_button(CLIENT_DATA* data, int key_button, int key_font, co
|
||||||
|
|
||||||
static void networkjoin_push_button(CLIENT_DATA* data)
|
static void networkjoin_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
if(interface->selected == SELECTED_BUTTON)
|
if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font && interface->button[i]->selected)
|
if(intface->button[i]->al_font && intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case BUTTON_NETWORKJOIN_CREATE:
|
case BUTTON_NETWORKJOIN_CREATE:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
if(networkjoin_check_field(data))
|
if(networkjoin_check_field(data))
|
||||||
cl_change_state(data, NETWORKLIST);
|
cl_change_state(data, NETWORKLIST);
|
||||||
break;
|
break;
|
||||||
case BUTTON_NETWORKJOIN_OUT:
|
case BUTTON_NETWORKJOIN_OUT:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKMODE);
|
cl_change_state(data, NETWORKMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_FIELD)
|
else if(intface->selected == SELECTED_FIELD)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->field_size; i++)
|
for(int i = 0; i < intface->field_size; i++)
|
||||||
if(interface->field[i]->selected)
|
if(intface->field[i]->selected)
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case FIELD_NETWORKJOIN_NICKNAME:
|
case FIELD_NETWORKJOIN_NICKNAME:
|
||||||
interface->field[i]->enter = true;
|
intface->field[i]->enter = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,17 +195,17 @@ static void networkjoin_push_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
static void networkjoin_change_selected(CLIENT_DATA* data)
|
static void networkjoin_change_selected(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
cl_change_selected(data->pairing.interface[data->state]);
|
cl_change_selected(data->pairing.intface[data->state]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool networkjoin_check_field(CLIENT_DATA* data)
|
static bool networkjoin_check_field(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
int field_size = interface->field_size;
|
int field_size = intface->field_size;
|
||||||
int field_filled_size = 0;
|
int field_filled_size = 0;
|
||||||
|
|
||||||
for(int i = 0; i < field_size; i++)
|
for(int i = 0; i < field_size; i++)
|
||||||
if(interface->field[i]->char_number > 0)
|
if(intface->field[i]->char_number > 0)
|
||||||
field_filled_size++;
|
field_filled_size++;
|
||||||
|
|
||||||
return field_size == field_filled_size;
|
return field_size == field_filled_size;
|
||||||
|
|
|
@ -116,14 +116,14 @@ void networklist_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networklist_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void networklist_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKLIST]->button_size > key_button)
|
if(data->pairing.intface[NETWORKLIST]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[NETWORKLIST]->button[key_button],
|
data->pairing.intface[NETWORKLIST]->button[key_button],
|
||||||
font->al_font, text,
|
font->al_font, text,
|
||||||
data->screen.width - (750 * data->screen.scale_factor + 60) / 2,
|
data->screen.width - (750 * data->screen.scale_factor + 60) / 2,
|
||||||
block_size * (index + 6) + (block_size / 4) + (block_size / 2) - font->size,
|
block_size * (index + 6) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
|
@ -140,7 +140,7 @@ void networklist_init_button(CLIENT_DATA* data, int key_button, int key_font, co
|
||||||
|
|
||||||
void networklist_init_list(CLIENT_DATA* data, int key_font)
|
void networklist_init_list(CLIENT_DATA* data, int key_font)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &data->pairing.interface[NETWORKLIST]->list;
|
CLIENT_LIST* list = &data->pairing.intface[NETWORKLIST]->list;
|
||||||
|
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
@ -168,7 +168,7 @@ void networklist_init_list(CLIENT_DATA* data, int key_font)
|
||||||
|
|
||||||
static void networklist_draw_list(CLIENT_DATA* data)
|
static void networklist_draw_list(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &data->pairing.interface[NETWORKLIST]->list;
|
CLIENT_LIST* list = &data->pairing.intface[NETWORKLIST]->list;
|
||||||
ALLEGRO_COLOR clr;
|
ALLEGRO_COLOR clr;
|
||||||
|
|
||||||
al_draw_rectangle(list->sx, list->sy, list->dx, list->dy, al_map_rgba_f(0.2, 0.2, 0.2, 0.2), 3);
|
al_draw_rectangle(list->sx, list->sy, list->dx, list->dy, al_map_rgba_f(0.2, 0.2, 0.2, 0.2), 3);
|
||||||
|
@ -241,14 +241,14 @@ static void networklist_enet_receive(CLIENT_DATA* data)
|
||||||
|
|
||||||
static void networklist_push_button(CLIENT_DATA* data)
|
static void networklist_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[NETWORKLIST];
|
CLIENT_INTERFACE* intface = data->pairing.intface[NETWORKLIST];
|
||||||
|
|
||||||
ENetPacket *packet;
|
ENetPacket *packet;
|
||||||
CLIENT_MESSAGE_JOINGAME message;
|
CLIENT_MESSAGE_JOINGAME message;
|
||||||
|
|
||||||
if(interface->selected == SELECTED_LIST)
|
if(intface->selected == SELECTED_LIST)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &interface->list;
|
CLIENT_LIST* list = &intface->list;
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
if(list->item[i].selected && data->network.games[i].count_connected < 3)
|
if(list->item[i].selected && data->network.games[i].count_connected < 3)
|
||||||
|
@ -263,17 +263,17 @@ static void networklist_push_button(CLIENT_DATA* data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_BUTTON)
|
else if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font && interface->button[i]->selected)
|
if(intface->button[i]->al_font && intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case BUTTON_NETWORKLIST_OUT:
|
case BUTTON_NETWORKLIST_OUT:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKMODE);
|
cl_change_state(data, NETWORKMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -283,21 +283,21 @@ static void networklist_push_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networklist_change_selected(CLIENT_DATA* data)
|
void networklist_change_selected(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[NETWORKLIST];
|
CLIENT_INTERFACE* intface = data->pairing.intface[NETWORKLIST];
|
||||||
|
|
||||||
if(interface->selected == SELECTED_BUTTON)
|
if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
interface->selected = SELECTED_LIST;
|
intface->selected = SELECTED_LIST;
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->selected)
|
if(intface->button[i]->selected)
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_LIST)
|
else if(intface->selected == SELECTED_LIST)
|
||||||
{
|
{
|
||||||
interface->selected = SELECTED_BUTTON;
|
intface->selected = SELECTED_BUTTON;
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
if(interface->list.item[i].selected)
|
if(intface->list.item[i].selected)
|
||||||
interface->list.item[i].selected = false;
|
intface->list.item[i].selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,13 +106,13 @@ void networkmode_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networkmode_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void networkmode_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKMODE]->button_size > key_button)
|
if(data->pairing.intface[NETWORKMODE]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[NETWORKMODE]->button[key_button],
|
data->pairing.intface[NETWORKMODE]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 3)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 3)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -124,25 +124,25 @@ void networkmode_init_button(CLIENT_DATA* data, int key_button, int key_font, co
|
||||||
|
|
||||||
static void networkmode_push_button(CLIENT_DATA* data)
|
static void networkmode_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font && interface->button[i]->selected)
|
if(intface->button[i]->al_font && intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case BUTTON_NETWORKMODE_CREATE:
|
case BUTTON_NETWORKMODE_CREATE:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKCREATE);
|
cl_change_state(data, NETWORKCREATE);
|
||||||
break;
|
break;
|
||||||
case BUTTON_NETWORKMODE_JOIN:
|
case BUTTON_NETWORKMODE_JOIN:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKJOIN);
|
cl_change_state(data, NETWORKJOIN);
|
||||||
break;
|
break;
|
||||||
case BUTTON_NETWORKMODE_OUT:
|
case BUTTON_NETWORKMODE_OUT:
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, MENU);
|
cl_change_state(data, MENU);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,13 +115,13 @@ void networkout_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networkout_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void networkout_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKOUT]->button_size > key_button)
|
if(data->pairing.intface[NETWORKOUT]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[NETWORKOUT]->button[key_button],
|
data->pairing.intface[NETWORKOUT]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 3)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 3)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -133,10 +133,10 @@ void networkout_init_button(CLIENT_DATA* data, int key_button, int key_font, con
|
||||||
|
|
||||||
static void networkout_push_button(CLIENT_DATA* data)
|
static void networkout_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->selected)
|
if(intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
|
@ -144,14 +144,14 @@ static void networkout_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
case BUTTON_NETWORKOUT_BACK:
|
case BUTTON_NETWORKOUT_BACK:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
al_hide_mouse_cursor(data->screen.display);
|
al_hide_mouse_cursor(data->screen.display);
|
||||||
cl_change_state(data, NETWORKGAME);
|
cl_change_state(data, NETWORKGAME);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BUTTON_NETWORKOUT_MENU:
|
case BUTTON_NETWORKOUT_MENU:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, NETWORKMODE);
|
cl_change_state(data, NETWORKMODE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ void networkparty_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networkparty_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void networkparty_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[NETWORKPARTY]->button_size > key_button)
|
if(data->pairing.intface[NETWORKPARTY]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
@ -130,7 +130,7 @@ void networkparty_init_button(CLIENT_DATA* data, int key_button, int key_font, c
|
||||||
index = 1;
|
index = 1;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[NETWORKPARTY]->button[key_button],
|
data->pairing.intface[NETWORKPARTY]->button[key_button],
|
||||||
font->al_font, text,
|
font->al_font, text,
|
||||||
data->screen.width - (750 * data->screen.scale_factor + 60) / 2,
|
data->screen.width - (750 * data->screen.scale_factor + 60) / 2,
|
||||||
block_size * (index + 5) + (block_size / 4) + (block_size / 2) - font->size,
|
block_size * (index + 5) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
|
@ -143,12 +143,12 @@ void networkparty_init_button(CLIENT_DATA* data, int key_button, int key_font, c
|
||||||
|
|
||||||
static void networkparty_draw_button(CLIENT_DATA* data)
|
static void networkparty_draw_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[NETWORKPARTY];
|
CLIENT_INTERFACE* intface = data->pairing.intface[NETWORKPARTY];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->al_font)
|
if(intface->button[i]->al_font)
|
||||||
{
|
{
|
||||||
CLIENT_BUTTON* btn = interface->button[i];
|
CLIENT_BUTTON* btn = intface->button[i];
|
||||||
|
|
||||||
if(data->network.is_creator)
|
if(data->network.is_creator)
|
||||||
{
|
{
|
||||||
|
@ -195,7 +195,7 @@ static void networkparty_draw_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
void networkparty_init_list(CLIENT_DATA* data, int key_font)
|
void networkparty_init_list(CLIENT_DATA* data, int key_font)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &data->pairing.interface[NETWORKPARTY]->list;
|
CLIENT_LIST* list = &data->pairing.intface[NETWORKPARTY]->list;
|
||||||
|
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
@ -223,7 +223,7 @@ void networkparty_init_list(CLIENT_DATA* data, int key_font)
|
||||||
|
|
||||||
static void networkparty_draw_list(CLIENT_DATA* data)
|
static void networkparty_draw_list(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &data->pairing.interface[NETWORKPARTY]->list;
|
CLIENT_LIST* list = &data->pairing.intface[NETWORKPARTY]->list;
|
||||||
ALLEGRO_COLOR clr;
|
ALLEGRO_COLOR clr;
|
||||||
|
|
||||||
al_draw_rectangle(list->sx, list->sy, list->dx, list->dy, al_map_rgba_f(0.2, 0.2, 0.2, 0.2), 3);
|
al_draw_rectangle(list->sx, list->sy, list->dx, list->dy, al_map_rgba_f(0.2, 0.2, 0.2, 0.2), 3);
|
||||||
|
@ -305,16 +305,16 @@ static void networkparty_enet_receive(CLIENT_DATA* data)
|
||||||
|
|
||||||
static void networkparty_push_button(CLIENT_DATA* data)
|
static void networkparty_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[NETWORKPARTY];
|
CLIENT_INTERFACE* intface = data->pairing.intface[NETWORKPARTY];
|
||||||
|
|
||||||
if(interface->selected == SELECTED_BUTTON)
|
if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->selected)
|
if(intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
|
@ -335,11 +335,11 @@ static void networkparty_push_button(CLIENT_DATA* data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_LIST)
|
else if(intface->selected == SELECTED_LIST)
|
||||||
{
|
{
|
||||||
if(data->network.is_creator)
|
if(data->network.is_creator)
|
||||||
{
|
{
|
||||||
CLIENT_LIST* list = &interface->list;
|
CLIENT_LIST* list = &intface->list;
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
if(list->item[i].selected && data->network.users[i].id != data->network.user_id)
|
if(list->item[i].selected && data->network.users[i].id != data->network.user_id)
|
||||||
|
@ -356,21 +356,21 @@ static void networkparty_push_button(CLIENT_DATA* data)
|
||||||
|
|
||||||
static void networkparty_change_selected(CLIENT_DATA* data)
|
static void networkparty_change_selected(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[NETWORKPARTY];
|
CLIENT_INTERFACE* intface = data->pairing.intface[NETWORKPARTY];
|
||||||
|
|
||||||
if(interface->selected == SELECTED_BUTTON)
|
if(intface->selected == SELECTED_BUTTON)
|
||||||
{
|
{
|
||||||
interface->selected = SELECTED_LIST;
|
intface->selected = SELECTED_LIST;
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->selected)
|
if(intface->button[i]->selected)
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
}
|
}
|
||||||
else if(interface->selected == SELECTED_LIST)
|
else if(intface->selected == SELECTED_LIST)
|
||||||
{
|
{
|
||||||
interface->selected = SELECTED_BUTTON;
|
intface->selected = SELECTED_BUTTON;
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
if(interface->list.item[i].selected)
|
if(intface->list.item[i].selected)
|
||||||
interface->list.item[i].selected = false;
|
intface->list.item[i].selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
game/pause.c
14
game/pause.c
|
@ -87,13 +87,13 @@ void pause_draw(CLIENT_DATA* data)
|
||||||
|
|
||||||
void pause_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
void pause_init_button(CLIENT_DATA* data, int key_button, int key_font, const char* text)
|
||||||
{
|
{
|
||||||
if(data->pairing.interface[PAUSE]->button_size > key_button)
|
if(data->pairing.intface[PAUSE]->button_size > key_button)
|
||||||
{
|
{
|
||||||
CLIENT_FONT* font = data->media.fonts[key_font];
|
CLIENT_FONT* font = data->media.fonts[key_font];
|
||||||
int block_size = data->screen.height / 8;
|
int block_size = data->screen.height / 8;
|
||||||
|
|
||||||
cl_add_interface_button(
|
cl_add_interface_button(
|
||||||
data->pairing.interface[PAUSE]->button[key_button],
|
data->pairing.intface[PAUSE]->button[key_button],
|
||||||
font->al_font, text, data->screen.width / 2,
|
font->al_font, text, data->screen.width / 2,
|
||||||
(block_size * (key_button + 3)) + (block_size / 4) + (block_size / 2) - font->size,
|
(block_size * (key_button + 3)) + (block_size / 4) + (block_size / 2) - font->size,
|
||||||
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
(data->screen.width / 2) - (750 * data->screen.scale_factor) / 2,
|
||||||
|
@ -105,10 +105,10 @@ void pause_init_button(CLIENT_DATA* data, int key_button, int key_font, const ch
|
||||||
|
|
||||||
static void pause_push_button(CLIENT_DATA* data)
|
static void pause_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
CLIENT_INTERFACE* interface = data->pairing.interface[data->state];
|
CLIENT_INTERFACE* intface = data->pairing.intface[data->state];
|
||||||
|
|
||||||
for(int i = 0; i < interface->button_size; i++)
|
for(int i = 0; i < intface->button_size; i++)
|
||||||
if(interface->button[i]->selected)
|
if(intface->button[i]->selected)
|
||||||
{
|
{
|
||||||
cl_play_sound(data, SAMPLE_ENTER);
|
cl_play_sound(data, SAMPLE_ENTER);
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ static void pause_push_button(CLIENT_DATA* data)
|
||||||
{
|
{
|
||||||
case BUTTON_PAUSE_BACK:
|
case BUTTON_PAUSE_BACK:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
al_hide_mouse_cursor(data->screen.display);
|
al_hide_mouse_cursor(data->screen.display);
|
||||||
cl_change_state(data, SINGLE);
|
cl_change_state(data, SINGLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BUTTON_PAUSE_MENU:
|
case BUTTON_PAUSE_MENU:
|
||||||
{
|
{
|
||||||
interface->button[i]->selected = false;
|
intface->button[i]->selected = false;
|
||||||
cl_change_state(data, MENU);
|
cl_change_state(data, MENU);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue