preps for slider work (nw)

This commit is contained in:
Miodrag Milanovic 2013-08-16 14:44:21 +00:00
parent a485774811
commit 71e5f10d78
5 changed files with 92 additions and 27 deletions

View File

@ -394,6 +394,9 @@ int running_machine::run(bool firstrun)
bool settingsloaded = config_load_settings(*this);
nvram_load(*this);
sound().ui_mute(false);
// initialize ui lists
ui_initialize(*this);
// display the startup screens
ui_display_startup_screens(*this, firstrun, !settingsloaded);

View File

@ -304,6 +304,16 @@ static void ui_exit(running_machine &machine)
}
/*-------------------------------------------------
ui_initialize - initialize ui lists
-------------------------------------------------*/
void ui_initialize(running_machine &machine)
{
/* initialize the on-screen display system */
slider_list = slider_current = slider_init(machine);
}
/*-------------------------------------------------
ui_display_startup_screens - display the
various startup screens
@ -322,9 +332,6 @@ int ui_display_startup_screens(running_machine &machine, int first_time, int sho
if (!first_time || (str > 0 && str < 60*5) || &machine.system() == &GAME_NAME(___empty) || (machine.debug_flags & DEBUG_FLAG_ENABLED) != 0)
show_gameinfo = show_warnings = show_disclaimer = FALSE;
/* initialize the on-screen display system */
slider_list = slider_current = slider_init(machine);
/* loop over states */
ui_set_handler(handler_ingame, 0);
for (state = 0; state < maxstate && !machine.scheduled_event_pending() && !ui_menu::stack_has_special_main_menu(); state++)

View File

@ -122,6 +122,9 @@ struct slider_state
/* main init/exit routines */
int ui_init(running_machine &machine);
/* initialize ui lists */
void ui_initialize(running_machine &machine);
/* display the startup screens */
int ui_display_startup_screens(running_machine &machine, int first_time, int show_disclaimer);

View File

@ -39,6 +39,7 @@
#include "emu.h"
#include "emuopts.h"
#include "ui.h"
#include "webengine.h"
#include "web/mongoose.h"
#include "web/json/json.h"
@ -75,6 +76,69 @@ static void get_qsvar(const struct mg_request_info *request_info,
mg_get_var(qs, strlen(qs == NULL ? "" : qs), name, dst, dst_len);
}
int web_engine::json_game_handler(struct mg_connection *conn)
{
Json::Value data;
data["name"] = m_machine->system().name;
data["description"] = m_machine->system().description;
data["year"] = m_machine->system().year;
data["manufacturer"] = m_machine->system().manufacturer;
data["parent"] = m_machine->system().parent;
data["source_file"] = m_machine->system().source_file;
data["flags"] = m_machine->system().flags;
Json::FastWriter writer;
const char *json = writer.write(data).c_str();
// Send HTTP reply to the client
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
"Content-Type: application/json\r\n"
"Content-Length: %d\r\n" // Always set Content-Length
"\r\n"
"%s",
(int)strlen(json), json);
// Returning non-zero tells mongoose that our function has replied to
// the client, and mongoose should not send client any more data.
return 1;
}
int web_engine::json_slider_handler(struct mg_connection *conn)
{
const slider_state *curslider;
astring tempstring;
/* add all sliders */
for (curslider = ui_get_slider_list(); curslider != NULL; curslider = curslider->next)
{
INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE);
printf("%d\n",curval);
/* UINT32 flags = 0;
if (curval > curslider->minval)
flags |= MENU_FLAG_LEFT_ARROW;
if (curval < curslider->maxval)
flags |= MENU_FLAG_RIGHT_ARROW;
item_append(curslider->description, tempstring, flags, (void *)curslider);
if (menuless_mode)
break;*/
}
/* add all sliders */
for (curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next)
{
INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE);
printf("%d\n",curval);
/*UINT32 flags = 0;
if (curval > curslider->minval)
flags |= MENU_FLAG_LEFT_ARROW;
if (curval < curslider->maxval)
flags |= MENU_FLAG_RIGHT_ARROW;
item_append(curslider->description, tempstring, flags, (void *)curslider);*/
}
return 1;
}
// This function will be called by mongoose on every new request.
int web_engine::begin_request_handler(struct mg_connection *conn)
{
@ -83,29 +147,11 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
{
if (!strcmp(request_info->uri, "/json/game"))
{
Json::Value data;
data["name"] = m_machine->system().name;
data["description"] = m_machine->system().description;
data["year"] = m_machine->system().year;
data["manufacturer"] = m_machine->system().manufacturer;
data["parent"] = m_machine->system().parent;
data["source_file"] = m_machine->system().source_file;
data["flags"] = m_machine->system().flags;
Json::FastWriter writer;
const char *json = writer.write(data).c_str();
// Send HTTP reply to the client
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
"Content-Type: application/json\r\n"
"Content-Length: %d\r\n" // Always set Content-Length
"\r\n"
"%s",
(int)strlen(json), json);
// Returning non-zero tells mongoose that our function has replied to
// the client, and mongoose should not send client any more data.
return 1;
return json_game_handler(conn);
}
if (!strcmp(request_info->uri, "/json/slider"))
{
return json_slider_handler(conn);
}
}
else if (!strncmp(request_info->uri, "/cmd",4))

View File

@ -60,7 +60,13 @@ public:
void websocket_ready_handler(struct mg_connection *conn);
int websocket_data_handler(struct mg_connection *conn, int flags, char *data, size_t data_len);
int begin_request_handler(struct mg_connection *conn);
void *websocket_keepalive();
void *websocket_keepalive();
protected:
// getters
running_machine &machine() const { return *m_machine; }
int json_game_handler(struct mg_connection *conn);
int json_slider_handler(struct mg_connection *conn);
private:
// internal state
emu_options & m_options;