slSubscriptionFactory::slSubscriptionFactory() 
: slSetObjFactory(__("Subscription"), __("New Subscription"), __("Create a new Subscription."), slsubscription_xpm)
{
    metaType = SLM_SUBSCRIPTION;
}
Beispiel #2
0
			break;
		case OBJECTSLISTREPORT:
			message = _("Slony listens list report");
			break;
	}

	return message;
}


///////////////////////////////////////////////////

#include "images/sllisten.pngc"
#include "images/sllistens.pngc"

slListenFactory::slListenFactory()
	: slNodeObjFactory(__("Listen"), __("New Listen"), __("Create a new Listen."), sllisten_png_img)
{
	metaType = SLM_LISTEN;
}


pgCollection *slListenFactory::CreateCollection(pgObject *obj)
{
	return new slListenCollection(GetCollectionFactory(), (slNode *)obj);
}


slListenFactory listenFactory;
static pgaCollectionFactory cf(&listenFactory, __("listens"), sllistens_png_img);
Beispiel #3
0
static int handle_info_req(login_client_t *c, bb_select_pkt *pkt) {
    uint32_t menu_id = LE32(pkt->menu_id);
    uint32_t item_id = LE32(pkt->item_id);
    uint16_t menu_code;
    int ship_num;
    char str[256];
    void *result;
    char **row;

    switch(menu_id & 0xFF) {
        /* Ship */
        case 0x01:
            /* If its a list, say nothing */
            if(item_id == 0) {
                return send_info_reply(c, __(c, "\tENothing here."));
            }

            /* We should have a ship ID as the item_id at this point, so query
               the db for the info we want. */
            sprintf(str, "SELECT name, players, games, menu_code, ship_number "
                    "FROM online_ships WHERE ship_id='%lu'",
                    (unsigned long)item_id);

            /* Query for what we're looking for */
            if(sylverant_db_query(&conn, str)) {
                return -1;
            }

            if(!(result = sylverant_db_result_store(&conn))) {
                return -2;
            }

            /* If we don't have a row, then the ship is offline */
            if(!(row = sylverant_db_result_fetch(result))) {
                return send_info_reply(c, __(c, "\tE\tC4That ship is now\n"
                                             "offline."));
            }

            /* Parse out the menu code */
            menu_code = (uint16_t)atoi(row[3]);
            ship_num = atoi(row[4]);

            /* Send the info reply */
            if(!menu_code) {
                sprintf(str, "%02X:%s\n%s %s\n%s %s", ship_num, row[0], row[1],
                        __(c, "Users"), row[2], __(c, "Teams"));
            }
            else {
                sprintf(str, "%02X:%c%c/%s\n%s %s\n%s %s", ship_num,
                        (char)menu_code, (char)(menu_code >> 8), row[0], row[1],
                        __(c, "Users"), row[2], __(c, "Teams"));
            }

            sylverant_db_result_free(result);

            return send_info_reply(c, str);

        default:
            /* Ignore any other info requests. */
            return 0;
    }
}
Beispiel #4
0
int64 IniInt64::operator=(int64 b)
{
	Mutex::Lock __(si64Mtx);
	value = b;
	return b;
}
Beispiel #5
0
	return srv->GetDatabase()->ExecuteSet(sql);
}

wxString pgForeignServerObject::ExecuteScalar(const wxString &sql)
{
	return srv->GetDatabase()->ExecuteScalar(sql);
}


bool pgForeignServerObject::ExecuteVoid(const wxString &sql)
{
	return srv->GetDatabase()->ExecuteVoid(sql);
}


///////////////////////////////////////////////////

#include "images/foreignserver.pngc"
#include "images/foreignserver-sm.pngc"
#include "images/foreignservers.pngc"

pgForeignServerFactory::pgForeignServerFactory()
	: pgForeignDataWrapperObjFactory(__("Foreign Server"), __("New Foreign Server..."),
	                                 __("Create a new Foreign Server."), foreignserver_png_img, foreignserver_sm_png_img)
{
}


pgForeignServerFactory foreignServerFactory;
static pgaCollectionFactory cf(&foreignServerFactory, __("Foreign Servers"), foreignservers_png_img);
Beispiel #6
0
void Heap::FreeRemote()
{
	LLOG("FreeRemote");
	Mutex::Lock __(mutex);
	FreeRemoteRaw();
}
Beispiel #7
0
VectorMap<String, String> GetIniKeys()
{
	Mutex::Lock __(sMtx);
	return clone(sIniKeys());
}
Beispiel #8
0
void SetTimeCallback(int delay_ms, Callback cb, void *id) {
	Mutex::Lock __(sTimerLock);
	ASSERT(abs(delay_ms) < 0x40000000);
	LLOG("SetTimeCallback " << delay_ms << " " << id);
	sTimeCallback(GetTickCount() + abs(delay_ms), delay_ms, cb, id);
}
Beispiel #9
0
			message = _("Privileges for external tables");
			break;
		case OBJECTSLISTREPORT:
			message = _("External tables list report");
			break;
	}

	return message;
}

/////////////////////////////

#include "images/exttable.pngc"
#include "images/exttable-sm.pngc"
#include "images/exttables.pngc"

gpExtTableFactory::gpExtTableFactory()
	: pgSchemaObjFactory(__("External Table"), __("New External Table..."), __("Create a new External Table."), exttable_png_img, exttable_sm_png_img)
{
	metaType = GP_EXTTABLE;
}


pgCollection *gpExtTableFactory::CreateCollection(pgObject *obj)
{
	return new gpExtTableCollection(GetCollectionFactory(), (pgSchema *)obj);
}

gpExtTableFactory extTableFactory;
static pgaCollectionFactory cf(&extTableFactory, __("External Tables"), exttables_png_img);
Beispiel #10
0
int main(void)
{
    FILE *image_file;
    int x, y;
    unsigned char r, g, b;
    int c[10];

    image_file = fopen("image-file-1.pnm", "wb");

    fputs("P6\n", image_file);

    fputs("500 500\n", image_file);
    fputs("255\n", image_file);

    /* The two for-loops are intact */
    for (y = 0; y < 500; y++) 
        for (x = 0; x < 500; x++) {

            /* The famous smiley algorithm,
             * here nicely written as a single statement :)
             */

                           (
                          _((
                         c[3]=
                        319),(c
                       [1]=196),
                      'A')&&y<(c[
                     2]=220))?((_(
                    362,(c[4]=155),
                   26))?__(0):__(c[7
                  ]=0xFF)):(_(3[c],1[
                 c],'L')&&y<(c[5]=231)
                )?__(0):(_('m',1[c],'A'
               )&&y<2[c])?(_((137),4[c],
              26)?__(0):__(7[c])):(_('m',
             1[c],'L')&&y<5[c])?__(0):(_(2
            [c],(c[6]=297),128)&&y>289)?(_(
             276,448,'R')?((r=251)+(g=192)
              +(b=0337)):((r=0207)+(g=25)
               +(b='E'))):(_(((2))[c],6[
                c],0213)&&y>0426)?__(0)
                 :(_((c[0]=0372),(0)[c
                  ],0345))?((r=0xFE)+
                   (g=0xDE)+(b='X'))
                    :(_(0[c],0[c],0
                     [c]))?__(0):(
                      (g=(x*(y))/
                       'F')+(b=(
                        r=(0))+
                         (0310
                          )))
                           ;

            /* Now that's beauty */

            fputc(r, image_file);
            fputc(g, image_file);
            fputc(b, image_file);
        }
    

    fclose(image_file);
    return 0;
}
Beispiel #11
0
void  Ctrl::InitTimer()
{
	Mutex::Lock __(sTimerLock);
	tevents();
}
Beispiel #12
0
// public Cloud() [instance] :6
void Cloud::ctor_4()
{
    uStackFrame __("Cloud", ".ctor()");
    ctor_3();
    InitializeUX();
}
Beispiel #13
0
pgCastFactory::pgCastFactory()
	: pgDatabaseObjFactory(__("Cast"), __("New Cast..."), __("Create a new Cast."), cast_png_img, cast_sm_png_img)
{
}
Beispiel #14
0
		case REFRESHINGDETAILS:
			message = _("Refreshing casts");
			break;
		case OBJECTSLISTREPORT:
			message = _("Casts list report");
			break;
	}

	return message;
}

/////////////////////////////

#include "images/cast.pngc"
#include "images/cast-sm.pngc"
#include "images/casts.pngc"

pgCastFactory::pgCastFactory()
	: pgDatabaseObjFactory(__("Cast"), __("New Cast..."), __("Create a new Cast."), cast_png_img, cast_sm_png_img)
{
}


pgCollection *pgCastFactory::CreateCollection(pgObject *obj)
{
	return new pgCastCollection(GetCollectionFactory(), (pgDatabase *)obj);
}

pgCastFactory castFactory;
static pgaCollectionFactory cf(&castFactory, __("Casts"), casts_png_img);
Beispiel #15
0
{
	wxString message = wxEmptyString;

	switch (kindOfMessage)
	{
		case RETRIEVINGDETAILS:
			message = _("Retrieving details on groups");
			break;
		case REFRESHINGDETAILS:
			message = _("Refreshing groups");
			break;
		case OBJECTSLISTREPORT:
			message = _("Groups list report");
			break;
	}

	return message;
}

#include "images/group.pngc"
#include "images/groups.pngc"

pgGroupFactory::pgGroupFactory()
	: pgServerObjFactory(__("Group"), __("New Group..."), __("Create a new Group."), group_png_img)
{
}


pgGroupFactory groupFactory;
static pgaCollectionFactory cf(&groupFactory, __("Groups"), groups_png_img);
Beispiel #16
0
gpExtTableFactory::gpExtTableFactory()
	: pgSchemaObjFactory(__("External Table"), __("New External Table..."), __("Create a new External Table."), exttable_png_img, exttable_sm_png_img)
{
	metaType = GP_EXTTABLE;
}
Beispiel #17
0
pgGroupFactory::pgGroupFactory()
	: pgServerObjFactory(__("Group"), __("New Group..."), __("Create a new Group."), group_png_img)
{
}
Beispiel #18
0
	smallClosedId = addIcon(closeddatabase_sm_png_img);
}

pgCollection *pgDatabaseFactory::CreateCollection(pgObject *obj)
{
	return new pgDatabaseCollection(GetCollectionFactory(), (pgServer *)obj);
}

pgCollection *pgDatabaseObjFactory::CreateCollection(pgObject *obj)
{
	return new pgDatabaseObjCollection(GetCollectionFactory(), (pgDatabase *)obj);
}


pgDatabaseFactory databaseFactory;
static pgaCollectionFactory cf(&databaseFactory, __("Databases"), databases_png_img);


disconnectDatabaseFactory::disconnectDatabaseFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : contextActionFactory(list)
{
	mnu->Append(id, _("Disconnec&t"), _("Disconnect from the selected database."));
}


wxWindow *disconnectDatabaseFactory::StartDialog(frmMain *form, pgObject *obj)
{
	ctlTree *browser = form->GetBrowser();
	pgDatabase *database = (pgDatabase *)obj;

	if (obj->CheckOpenDialogs(browser, browser->GetSelection()))
	{
Beispiel #19
0
void SetIniFile(const char *name) {
	Mutex::Lock __(sMtx);
	strncpy(sIniFile, name, 511);
	ReloadIniFile();
}
Beispiel #20
0
// public static generated Fuse.Preview.ISelection get_Selection() [static] :5938
uObject* SelectionManager::Selection()
{
    uStackFrame __("Fuse.Preview.SelectionManager", "get_Selection()");
    return SelectionManager::_Selection();
}
Beispiel #21
0
String GetIniKey(const char *id, const String& def) {
	ASSERT_(IsMainRunning(), "GetIniKey is allowed only after APP_MAIN has started");
	Mutex::Lock __(sMtx);
	return sIniKeys().Get(id, def);
}
Beispiel #22
0
// private static generated void set_Selection(Fuse.Preview.ISelection value) [static] :5938
void SelectionManager::Selection(uObject* value)
{
    uStackFrame __("Fuse.Preview.SelectionManager", "set_Selection(Fuse.Preview.ISelection)");
    SelectionManager::_Selection() = value;
}
Beispiel #23
0
void ReloadIniFile()
{
	Mutex::Lock __(sMtx);
	ini_version__++;
}
Beispiel #24
0
// public static generated void remove_SelectionChanged(Uno.EventHandler<Uno.EventArgs> value) [static] :5939
void SelectionManager::remove_SelectionChanged(uDelegate* value)
{
    uStackFrame __("Fuse.Preview.SelectionManager", "remove_SelectionChanged(Uno.EventHandler<Uno.EventArgs>)");
    SelectionManager::SelectionChanged1() = uCast<uDelegate*>(::g::Uno::Delegate::Remove(SelectionManager::SelectionChanged1(), value), ::TYPES[1/*Uno.EventHandler<Uno.EventArgs>*/]);
}
Beispiel #25
0
pgForeignServerFactory::pgForeignServerFactory()
	: pgForeignDataWrapperObjFactory(__("Foreign Server"), __("New Foreign Server..."),
	                                 __("Create a new Foreign Server."), foreignserver_png_img, foreignserver_sm_png_img)
{
}
            if (browser)
            {
                browser->AppendObject(coll, subscription);
				subscriptions->MoveNext();
            }
            else
                break;
        }

		delete subscriptions;
    }
    return subscription;
}


///////////////////////////////////////////////////

#include "images/slsubscription.xpm"
#include "images/slsubscriptions.xpm"

slSubscriptionFactory::slSubscriptionFactory() 
: slSetObjFactory(__("Subscription"), __("New Subscription"), __("Create a new Subscription."), slsubscription_xpm)
{
    metaType = SLM_SUBSCRIPTION;
}


slSubscriptionFactory subscriptionFactory;
static pgaCollectionFactory cf(&subscriptionFactory, __("Subscriptions"), slsubscriptions_xpm);
Beispiel #27
0
slListenFactory::slListenFactory()
	: slNodeObjFactory(__("Listen"), __("New Listen"), __("Create a new Listen."), sllisten_png_img)
{
	metaType = SLM_LISTEN;
}
Beispiel #28
0
namespace ui {
std::vector<submenu::option> const submenu::misc_options = {
	{ submenu::option_type::HEAD, __("Miscellaneous Options") },
	{ submenu::option_type::UI,   __("Re-select last machine played"),           OPTION_REMEMBER_LAST },
	{ submenu::option_type::UI,   __("Enlarge images in the right panel"),       OPTION_ENLARGE_SNAPS },
	{ submenu::option_type::UI,   __("DATs info"),                               OPTION_DATS_ENABLED },
	{ submenu::option_type::EMU,  __("Cheats"),                                  OPTION_CHEAT },
	{ submenu::option_type::EMU,  __("Show mouse pointer"),                      OPTION_UI_MOUSE },
	{ submenu::option_type::EMU,  __("Confirm quit from machines"),              OPTION_CONFIRM_QUIT },
	{ submenu::option_type::EMU,  __("Skip information screen at startup"),      OPTION_SKIP_GAMEINFO },
	{ submenu::option_type::UI,   __("Force 4:3 aspect for snapshot display"),   OPTION_FORCED4X3 },
	{ submenu::option_type::UI,   __("Use image as background"),                 OPTION_USE_BACKGROUND },
	{ submenu::option_type::UI,   __("Skip bios selection menu"),                OPTION_SKIP_BIOS_MENU },
	{ submenu::option_type::UI,   __("Skip software parts selection menu"),      OPTION_SKIP_PARTS_MENU },
	{ submenu::option_type::UI,   __("Info auto audit"),                         OPTION_INFO_AUTO_AUDIT },
	{ submenu::option_type::UI,   __("Hide romless machine from available list"),OPTION_HIDE_ROMLESS },
};

std::vector<submenu::option> const submenu::advanced_options = {
	{ submenu::option_type::HEAD, __("Advanced Options") },
	{ submenu::option_type::HEAD, __("Performance Options") },
	{ submenu::option_type::EMU,  __("Auto frame skip"),                         OPTION_AUTOFRAMESKIP },
	{ submenu::option_type::EMU,  __("Frame skip"),                              OPTION_FRAMESKIP },
	{ submenu::option_type::EMU,  __("Throttle"),                                OPTION_THROTTLE },
	{ submenu::option_type::EMU,  __("Sleep"),                                   OPTION_SLEEP },
	{ submenu::option_type::EMU,  __("Speed"),                                   OPTION_SPEED },
	{ submenu::option_type::EMU,  __("Refresh speed"),                           OPTION_REFRESHSPEED },

	{ submenu::option_type::HEAD, __("Rotation Options") },
	{ submenu::option_type::EMU,  __("Rotate"),                                  OPTION_ROTATE },
	{ submenu::option_type::EMU,  __("Rotate right"),                            OPTION_ROR },
	{ submenu::option_type::EMU,  __("Rotate left"),                             OPTION_ROL },
	{ submenu::option_type::EMU,  __("Auto rotate right"),                       OPTION_AUTOROR },
	{ submenu::option_type::EMU,  __("Auto rotate left"),                        OPTION_AUTOROL },
	{ submenu::option_type::EMU,  __("Flip X"),                                  OPTION_FLIPX },
	{ submenu::option_type::EMU,  __("Flip Y"),                                  OPTION_FLIPY },

	{ submenu::option_type::HEAD, __("Artwork Options") },
	{ submenu::option_type::EMU,  __("Artwork Crop"),                            OPTION_ARTWORK_CROP },
	{ submenu::option_type::EMU,  __("Use Backdrops"),                           OPTION_USE_BACKDROPS },
	{ submenu::option_type::EMU,  __("Use Overlays"),                            OPTION_USE_OVERLAYS },
	{ submenu::option_type::EMU,  __("Use Bezels"),                              OPTION_USE_BEZELS },
	{ submenu::option_type::EMU,  __("Use Control Panels"),                      OPTION_USE_CPANELS },
	{ submenu::option_type::EMU,  __("Use Marquees"),                            OPTION_USE_MARQUEES },

	{ submenu::option_type::HEAD, __("State/Playback Options") },
	{ submenu::option_type::EMU,  __("Automatic save/restore"),                  OPTION_AUTOSAVE },
	{ submenu::option_type::EMU,  __("Bilinear snapshot"),                       OPTION_SNAPBILINEAR },
	{ submenu::option_type::EMU,  __("Burn-in"),                                 OPTION_BURNIN },

	{ submenu::option_type::HEAD, __("Input Options") },
	{ submenu::option_type::EMU,  __("Coin lockout"),                            OPTION_COIN_LOCKOUT },
	{ submenu::option_type::EMU,  __("Mouse"),                                   OPTION_MOUSE },
	{ submenu::option_type::EMU,  __("Joystick"),                                OPTION_JOYSTICK },
	{ submenu::option_type::EMU,  __("Lightgun"),                                OPTION_LIGHTGUN },
	{ submenu::option_type::EMU,  __("Multi-keyboard"),                          OPTION_MULTIKEYBOARD },
	{ submenu::option_type::EMU,  __("Multi-mouse"),                             OPTION_MULTIMOUSE },
	{ submenu::option_type::EMU,  __("Steadykey"),                               OPTION_STEADYKEY },
	{ submenu::option_type::EMU,  __("UI active"),                               OPTION_UI_ACTIVE },
	{ submenu::option_type::EMU,  __("Offscreen reload"),                        OPTION_OFFSCREEN_RELOAD },
	{ submenu::option_type::EMU,  __("Joystick deadzone"),                       OPTION_JOYSTICK_DEADZONE },
	{ submenu::option_type::EMU,  __("Joystick saturation"),                     OPTION_JOYSTICK_SATURATION },
	{ submenu::option_type::EMU,  __("Natural keyboard"),                        OPTION_NATURAL_KEYBOARD },
	{ submenu::option_type::EMU,  __("Simultaneous contradictory"),              OPTION_JOYSTICK_CONTRADICTORY },
	{ submenu::option_type::EMU,  __("Coin impulse"),                            OPTION_COIN_IMPULSE },
};

std::vector<submenu::option> const submenu::control_options = {
	{ submenu::option_type::HEAD, __("Device Mapping") },
	{ submenu::option_type::EMU,  __("Lightgun Device Assignment"),              OPTION_LIGHTGUN_DEVICE },
	{ submenu::option_type::EMU,  __("Trackball Device Assignment"),             OPTION_TRACKBALL_DEVICE },
	{ submenu::option_type::EMU,  __("Pedal Device Assignment"),                 OPTION_PEDAL_DEVICE },
	{ submenu::option_type::EMU,  __("Adstick Device Assignment"),               OPTION_ADSTICK_DEVICE },
	{ submenu::option_type::EMU,  __("Paddle Device Assignment"),                OPTION_PADDLE_DEVICE },
	{ submenu::option_type::EMU,  __("Dial Device Assignment"),                  OPTION_DIAL_DEVICE },
	{ submenu::option_type::EMU,  __("Positional Device Assignment"),            OPTION_POSITIONAL_DEVICE },
	{ submenu::option_type::EMU,  __("Mouse Device Assignment"),                 OPTION_MOUSE_DEVICE }
};

std::vector<submenu::option> const submenu::video_options = {
	{ submenu::option_type::HEAD, __("Video Options") },
	{ submenu::option_type::OSD,  __("Video Mode"),                              OSDOPTION_VIDEO },
	{ submenu::option_type::OSD,  __("Number Of Screens"),                       OSDOPTION_NUMSCREENS },
#if defined(UI_WINDOWS) && !defined(UI_SDL)
	{ submenu::option_type::OSD,  __("Triple Buffering"),                        WINOPTION_TRIPLEBUFFER },
	{ submenu::option_type::OSD,  __("HLSL"),                                    WINOPTION_HLSL_ENABLE },
#endif
	{ submenu::option_type::OSD,  __("GLSL"),                                    OSDOPTION_GL_GLSL },
	{ submenu::option_type::OSD,  __("Bilinear Filtering"),                      OSDOPTION_FILTER },
	{ submenu::option_type::OSD,  __("Bitmap Prescaling"),                       OSDOPTION_PRESCALE },
	{ submenu::option_type::OSD,  __("Window Mode"),                             OSDOPTION_WINDOW },
	{ submenu::option_type::EMU,  __("Enforce Aspect Ratio"),                    OPTION_KEEPASPECT },
	{ submenu::option_type::OSD,  __("Start Out Maximized"),                     OSDOPTION_MAXIMIZE },
	{ submenu::option_type::OSD,  __("Synchronized Refresh"),                    OSDOPTION_SYNCREFRESH },
	{ submenu::option_type::OSD,  __("Wait Vertical Sync"),                      OSDOPTION_WAITVSYNC }
};

//std::vector<submenu::option> const submenu::export_options = {
//  { ui_submenu::option_type::COMMAND, __("Export XML format (like -listxml)"),               "exportxml" },
//  { ui_submenu::option_type::COMMAND, __("Export TXT format (like -listfull)"),              "exporttxt" },
//};


//-------------------------------------------------
//  ctor / dtor
//-------------------------------------------------

submenu::submenu(mame_ui_manager &mui, render_container &container, std::vector<option> const &suboptions, const game_driver *drv, emu_options *options)
	: submenu(mui, container, std::vector<option>(suboptions), drv, options)
{
}

submenu::submenu(mame_ui_manager &mui, render_container &container, std::vector<option> &&suboptions, const game_driver *drv, emu_options *options)
	: menu(mui, container)
	, m_options(std::move(suboptions))
	, m_driver(drv)
{
	core_options *opts = nullptr;
	if (m_driver == nullptr)
		opts = dynamic_cast<core_options*>(&mui.machine().options());
	else
		opts = dynamic_cast<core_options*>(options);

	for (auto & sm_option : m_options)
	{
		switch (sm_option.type)
		{
		case option_type::EMU:
			sm_option.entry = opts->get_entry(sm_option.name);
			sm_option.options = opts;
			if (sm_option.entry->type() == OPTION_STRING)
			{
				sm_option.value.clear();
				std::string namestr(sm_option.entry->description());
				int lparen = namestr.find_first_of('(', 0);
				int vslash = namestr.find_first_of('|', lparen + 1);
				int rparen = namestr.find_first_of(')', vslash + 1);
				if (lparen != -1 && vslash != -1 && rparen != -1)
				{
					int semi;
					namestr.erase(rparen);
					namestr.erase(0, lparen + 1);
					while ((semi = namestr.find_first_of('|')) != -1)
					{
						sm_option.value.emplace_back(namestr.substr(0, semi));
						namestr.erase(0, semi + 1);
					}
					sm_option.value.emplace_back(namestr);
				}
			}
			break;
		case option_type::OSD:
			sm_option.entry = opts->get_entry(sm_option.name);
			sm_option.options = opts;
			if (sm_option.entry->type() == OPTION_STRING)
			{
				sm_option.value.clear();
				std::string descr(sm_option.entry->description()), delim(", ");
				descr.erase(0, descr.find(":") + 2);
				size_t p1, p2 = 0;
				while ((p1 = descr.find_first_not_of(delim, p2)) != std::string::npos)
				{
					p2 = descr.find_first_of(delim, p1 + 1);
					if (p2 != std::string::npos)
					{
						std::string txt(descr.substr(p1, p2 - p1));
						if (txt != "or")
							sm_option.value.push_back(txt);
					}
					else
					{
						sm_option.value.push_back(descr.substr(p1));
						break;
					}
				}
			}
			break;
		case option_type::UI:
			sm_option.entry = mui.options().get_entry(sm_option.name);
			sm_option.options = dynamic_cast<core_options*>(&mui.options());
			break;
		default:
			break;
		}
	}
}

submenu::~submenu()
{
}

//-------------------------------------------------
//  handlethe options menu
//-------------------------------------------------

void submenu::handle()
{
	bool changed = false;
	std::string error_string, tmptxt;
	float f_cur, f_step;

	// process the menu
	const event *menu_event = process(PROCESS_LR_REPEAT);

	if (menu_event != nullptr && menu_event->itemref != nullptr &&
			(menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT || menu_event->iptkey == IPT_UI_SELECT))
	{
		option &sm_option = *reinterpret_cast<option *>(menu_event->itemref);

		switch (sm_option.type)
		{
		case option_type::EMU:
		case option_type::UI:
		case option_type::OSD:
			switch (sm_option.entry->type())
			{
			case OPTION_BOOLEAN:
				changed = true;
				sm_option.options->set_value(sm_option.name, !strcmp(sm_option.entry->value(),"1") ? "0" : "1", OPTION_PRIORITY_CMDLINE, error_string);
				sm_option.entry->mark_changed();
				break;
			case OPTION_INTEGER:
				if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
				{
					changed = true;
					int i_cur = atoi(sm_option.entry->value());
					(menu_event->iptkey == IPT_UI_LEFT) ? i_cur-- : i_cur++;
					sm_option.options->set_value(sm_option.name, i_cur, OPTION_PRIORITY_CMDLINE, error_string);
					sm_option.entry->mark_changed();
				}
				break;
			case OPTION_FLOAT:
				if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
				{
					changed = true;
					f_cur = atof(sm_option.entry->value());
					if (sm_option.entry->has_range())
					{
						f_step = atof(sm_option.entry->minimum());
						if (f_step <= 0.0f) {
							int pmin = getprecisionchr(sm_option.entry->minimum());
							int pmax = getprecisionchr(sm_option.entry->maximum());
							tmptxt = '1' + std::string((pmin > pmax) ? pmin : pmax, '0');
							f_step = 1 / atof(tmptxt.c_str());
						}
					}
					else
					{
						int precision = getprecisionchr(sm_option.entry->default_value());
						tmptxt = '1' + std::string(precision, '0');
						f_step = 1 / atof(tmptxt.c_str());
					}
					if (menu_event->iptkey == IPT_UI_LEFT)
						f_cur -= f_step;
					else
						f_cur += f_step;
					tmptxt = string_format("%g", f_cur);
					sm_option.options->set_value(sm_option.name, tmptxt.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
					sm_option.entry->mark_changed();
				}
				break;
			case OPTION_STRING:
				if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
				{
					changed = true;
					std::string v_cur(sm_option.entry->value());
					int cur_value = std::distance(sm_option.value.begin(), std::find(sm_option.value.begin(), sm_option.value.end(), v_cur));
					if (menu_event->iptkey == IPT_UI_LEFT)
						v_cur = sm_option.value[--cur_value];
					else
						v_cur = sm_option.value[++cur_value];
					sm_option.options->set_value(sm_option.name, v_cur.c_str(), OPTION_PRIORITY_CMDLINE, error_string);
					sm_option.entry->mark_changed();
				}
				break;
			}
			break;
		default:
			osd_printf_error("Unhandled option: %s", _(sm_option.description));
			break;
		}
	}

	if (changed)
		reset(reset_options::REMEMBER_REF);
}

//-------------------------------------------------
//  populate
//-------------------------------------------------

void submenu::populate()
{
	UINT32 arrow_flags;

	// add options
	for (auto sm_option = m_options.begin(); sm_option < m_options.end(); ++sm_option)
	{
		// skip first heading (is menu title)
		if (sm_option == m_options.begin() && sm_option->type == option_type::HEAD) continue;

		switch (sm_option->type)
		{
		case option_type::HEAD:
			item_append(_(sm_option->description), "", FLAG_DISABLE | FLAG_UI_HEADING, nullptr);
			break;
		case option_type::SEP:
			item_append(menu_item_type::SEPARATOR);
			break;
		case option_type::CMD:
			item_append(_(sm_option->description), "", 0, static_cast<void*>(&(*sm_option)));
			break;
		case option_type::EMU:
		case option_type::UI:
		case option_type::OSD:
			switch (sm_option->entry->type())
			{
			case OPTION_BOOLEAN:
				arrow_flags = sm_option->options->bool_value(sm_option->name) ? FLAG_RIGHT_ARROW : FLAG_LEFT_ARROW;
				item_append(_(sm_option->description),
					(arrow_flags == FLAG_RIGHT_ARROW) ? "On" : "Off",
					arrow_flags,
					static_cast<void*>(&(*sm_option)));
				break;
			case OPTION_INTEGER:
				{
					int i_min, i_max;
					int i_cur = atoi(sm_option->entry->value());
					if (sm_option->entry->has_range())
					{
						i_min = atoi(sm_option->entry->minimum());
						i_max = atoi(sm_option->entry->maximum());
					}
					else
					{
						i_min = std::numeric_limits<int>::min();
						i_max = std::numeric_limits<int>::max();
					}
					arrow_flags = get_arrow_flags(i_min, i_max, i_cur);
					item_append(_(sm_option->description),
						sm_option->entry->value(),
						arrow_flags,
						static_cast<void*>(&(*sm_option)));
				}
				break;
			case OPTION_FLOAT:
				{
					float f_min, f_max;
					float f_cur = atof(sm_option->entry->value());
					if (sm_option->entry->has_range())
					{
						f_min = atof(sm_option->entry->minimum());
						f_max = atof(sm_option->entry->maximum());
					}
					else
					{
						f_min = 0.0f;
						f_max = std::numeric_limits<float>::max();
					}
					arrow_flags = get_arrow_flags(f_min, f_max, f_cur);
					std::string tmptxt = string_format("%g", f_cur);
					item_append(_(sm_option->description),
						tmptxt.c_str(),
						arrow_flags,
						static_cast<void*>(&(*sm_option)));
				}
				break;
			case OPTION_STRING:
				{
					std::string const v_cur(sm_option->entry->value());
					int const cur_value = std::distance(sm_option->value.begin(), std::find(sm_option->value.begin(), sm_option->value.end(), v_cur));
					arrow_flags = get_arrow_flags(0, int(unsigned(sm_option->value.size() - 1)), cur_value);
					item_append(_(sm_option->description),
							sm_option->options->value(sm_option->name),
							arrow_flags, static_cast<void*>(&(*sm_option)));
				}
				break;
			default:
				arrow_flags = FLAG_RIGHT_ARROW;
				item_append(_(sm_option->description),
					sm_option->options->value(sm_option->name),
					arrow_flags, static_cast<void*>(&(*sm_option)));
				break;
			}
			break;
		default:
			osd_printf_error("Unknown option type: %s", _(sm_option->description));
			break;
		}
	}

	item_append(menu_item_type::SEPARATOR);
	custombottom = customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
}

//-------------------------------------------------
//  perform our special rendering
//-------------------------------------------------

void submenu::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2)
{
	float width;

	ui().draw_text_full(container(), _(m_options[0].description), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
			mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);
	width += 2 * UI_BOX_LR_BORDER;
	float maxwidth = std::max(origx2 - origx1, width);

	// compute our bounds
	float x1 = 0.5f - 0.5f * maxwidth;
	float x2 = x1 + maxwidth;
	float y1 = origy1 - top;
	float y2 = origy1 - UI_BOX_TB_BORDER;

	// draw a box
	ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);

	// take off the borders
	x1 += UI_BOX_LR_BORDER;
	x2 -= UI_BOX_LR_BORDER;
	y1 += UI_BOX_TB_BORDER;

	// draw the text within it
	ui().draw_text_full(container(), _(m_options[0].description), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
		mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);

	if (selectedref != nullptr)
	{
		option &selected_sm_option = *reinterpret_cast<option *>(selectedref);
		if (selected_sm_option.entry != nullptr)
		{
			ui().draw_text_full(container(), selected_sm_option.entry->description(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
					mame_ui_manager::NONE, rgb_t::white, rgb_t::black, &width, nullptr);

			width += 2 * UI_BOX_LR_BORDER;
			maxwidth = std::max(origx2 - origx1, width);

			// compute our bounds
			x1 = 0.5f - 0.5f * maxwidth;
			x2 = x1 + maxwidth;
			y1 = origy2 + UI_BOX_TB_BORDER;
			y2 = origy2 + bottom;

			// draw a box
			ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_RED_COLOR);

			// take off the borders
			x1 += UI_BOX_LR_BORDER;
			x2 -= UI_BOX_LR_BORDER;
			y1 += UI_BOX_TB_BORDER;

			// draw the text within it
			ui().draw_text_full(container(), selected_sm_option.entry->description(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
					mame_ui_manager::NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, nullptr, nullptr);
		}
	}
}

} // namespace ui