mirror of
https://github.com/holub/mame
synced 2025-07-02 16:49:22 +03:00
ui: split a few more menu entries from miscmenu.c to separate files,
so to avoid having too much assorted stuff in miscmenu.c (now it is down to a reasonable size). nw.
This commit is contained in:
parent
d02f770764
commit
a1e9e0f228
@ -120,6 +120,7 @@ EMUOBJS = \
|
||||
$(EMUOBJ)/ui/mainmenu.o \
|
||||
$(EMUOBJ)/ui/miscmenu.o \
|
||||
$(EMUOBJ)/ui/barcode.o \
|
||||
$(EMUOBJ)/ui/cheatopt.o \
|
||||
$(EMUOBJ)/ui/devopt.o \
|
||||
$(EMUOBJ)/ui/filemngr.o \
|
||||
$(EMUOBJ)/ui/filesel.o \
|
||||
@ -127,9 +128,11 @@ EMUOBJS = \
|
||||
$(EMUOBJ)/ui/info.o \
|
||||
$(EMUOBJ)/ui/inputmap.o \
|
||||
$(EMUOBJ)/ui/selgame.o \
|
||||
$(EMUOBJ)/ui/sliders.o \
|
||||
$(EMUOBJ)/ui/slotopt.o \
|
||||
$(EMUOBJ)/ui/swlist.o \
|
||||
$(EMUOBJ)/ui/tapectrl.o \
|
||||
$(EMUOBJ)/ui/videoopt.o \
|
||||
$(EMUOBJ)/ui/viewgfx.o \
|
||||
$(EMUOBJ)/validity.o \
|
||||
$(EMUOBJ)/video.o \
|
||||
|
133
src/emu/ui/cheatopt.c
Normal file
133
src/emu/ui/cheatopt.c
Normal file
@ -0,0 +1,133 @@
|
||||
/*********************************************************************
|
||||
|
||||
ui/cheatopt.c
|
||||
|
||||
Internal menu for the cheat interface.
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "cheat.h"
|
||||
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/cheatopt.h"
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_cheat - handle the cheat menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_cheat::handle()
|
||||
{
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT);
|
||||
|
||||
/* handle events */
|
||||
if (menu_event != NULL && menu_event->itemref != NULL)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
/* clear cheat comment on any movement or keypress */
|
||||
popmessage(NULL);
|
||||
|
||||
/* handle reset all + reset all cheats for reload all option */
|
||||
if ((FPTR)menu_event->itemref < 3 && menu_event->iptkey == IPT_UI_SELECT)
|
||||
{
|
||||
for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next())
|
||||
if (curcheat->select_default_state())
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
/* handle individual cheats */
|
||||
else if ((FPTR)menu_event->itemref > 2)
|
||||
{
|
||||
cheat_entry *curcheat = reinterpret_cast<cheat_entry *>(menu_event->itemref);
|
||||
const char *string;
|
||||
switch (menu_event->iptkey)
|
||||
{
|
||||
/* if selected, activate a oneshot */
|
||||
case IPT_UI_SELECT:
|
||||
changed = curcheat->activate();
|
||||
break;
|
||||
|
||||
/* if cleared, reset to default value */
|
||||
case IPT_UI_CLEAR:
|
||||
changed = curcheat->select_default_state();
|
||||
break;
|
||||
|
||||
/* left decrements */
|
||||
case IPT_UI_LEFT:
|
||||
changed = curcheat->select_previous_state();
|
||||
break;
|
||||
|
||||
/* right increments */
|
||||
case IPT_UI_RIGHT:
|
||||
changed = curcheat->select_next_state();
|
||||
break;
|
||||
|
||||
/* bring up display comment if one exists */
|
||||
case IPT_UI_DISPLAY_COMMENT:
|
||||
case IPT_UI_UP:
|
||||
case IPT_UI_DOWN:
|
||||
string = curcheat->comment();
|
||||
if (string != NULL && string[0] != 0)
|
||||
popmessage("Cheat Comment:\n%s", string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* handle reload all */
|
||||
if ((FPTR)menu_event->itemref == 2 && menu_event->iptkey == IPT_UI_SELECT)
|
||||
{
|
||||
/* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */
|
||||
machine().cheat().reload();
|
||||
|
||||
/* display the reloaded cheats */
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
popmessage("All cheats reloaded");
|
||||
}
|
||||
|
||||
/* if things changed, update */
|
||||
if (changed)
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_cheat_populate - populate the cheat menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container)
|
||||
{
|
||||
}
|
||||
|
||||
void ui_menu_cheat::populate()
|
||||
{
|
||||
/* iterate over cheats */
|
||||
astring text;
|
||||
astring subtext;
|
||||
for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next())
|
||||
{
|
||||
UINT32 flags;
|
||||
curcheat->menu_text(text, subtext, flags);
|
||||
item_append(text, subtext, flags, curcheat);
|
||||
}
|
||||
|
||||
/* add a separator */
|
||||
item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
|
||||
|
||||
/* add a reset all option */
|
||||
item_append("Reset All", NULL, 0, (void *)1);
|
||||
|
||||
/* add a reload all cheats option */
|
||||
item_append("Reload All", NULL, 0, (void *)2);
|
||||
}
|
||||
|
||||
ui_menu_cheat::~ui_menu_cheat()
|
||||
{
|
||||
}
|
25
src/emu/ui/cheatopt.h
Normal file
25
src/emu/ui/cheatopt.h
Normal file
@ -0,0 +1,25 @@
|
||||
/***************************************************************************
|
||||
|
||||
ui/cheatopt.h
|
||||
|
||||
Internal menu for the cheat interface.
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UI_CHEATOPT_H__
|
||||
#define __UI_CHEATOPT_H__
|
||||
|
||||
class ui_menu_cheat : public ui_menu {
|
||||
public:
|
||||
ui_menu_cheat(running_machine &machine, render_container *container);
|
||||
virtual ~ui_menu_cheat();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
};
|
||||
|
||||
#endif /* __UI_CHEATOPT_H__ */
|
@ -6,15 +6,9 @@
|
||||
|
||||
TODO
|
||||
- Restrict directory listing by file extension
|
||||
- Support file manager invocation from the main menu for
|
||||
required images
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "emu.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/swlist.h"
|
||||
|
@ -10,25 +10,27 @@
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "audit.h"
|
||||
#include "crsshair.h"
|
||||
#include "osdnet.h"
|
||||
#include "emuopts.h"
|
||||
#include "ui/ui.h"
|
||||
#include "rendutil.h"
|
||||
#include "cheat.h"
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/filemngr.h"
|
||||
#include "ui/filesel.h"
|
||||
#include "ui/barcode.h"
|
||||
#include "ui/cheatopt.h"
|
||||
#include "ui/info.h"
|
||||
#include "ui/inputmap.h"
|
||||
#include "ui/mainmenu.h"
|
||||
#include "ui/miscmenu.h"
|
||||
#include "ui/selgame.h"
|
||||
#include "ui/sliders.h"
|
||||
#include "ui/slotopt.h"
|
||||
#include "ui/tapectrl.h"
|
||||
#include "audit.h"
|
||||
#include "crsshair.h"
|
||||
#include <ctype.h>
|
||||
#include "ui/videoopt.h"
|
||||
#include "imagedev/cassette.h"
|
||||
#include "imagedev/bitbngr.h"
|
||||
#include "machine/bcreader.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
#ifndef __UI_MAINMENU_H__
|
||||
#define __UI_MAINMENU_H__
|
||||
|
||||
#include "crsshair.h"
|
||||
#include "drivenum.h"
|
||||
|
||||
class ui_menu_main : public ui_menu {
|
||||
|
@ -11,13 +11,12 @@
|
||||
|
||||
#include "emu.h"
|
||||
#include "emuopts.h"
|
||||
#include "ui/ui.h"
|
||||
#include "rendutil.h"
|
||||
#include "uiinput.h"
|
||||
#include "cheat.h"
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/mainmenu.h"
|
||||
#include "ui/miscmenu.h"
|
||||
#include <ctype.h>
|
||||
#include "ui/cheatopt.h"
|
||||
|
||||
|
||||
|
||||
|
@ -9,46 +9,14 @@
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "emu.h"
|
||||
#include "emuopts.h"
|
||||
|
||||
#include "cheat.h"
|
||||
#include "osdnet.h"
|
||||
#include "rendutil.h"
|
||||
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/miscmenu.h"
|
||||
#include "ui/filemngr.h"
|
||||
|
||||
#include "osdepend.h"
|
||||
|
||||
/*-------------------------------------------------
|
||||
ui_slider_ui_handler - pushes the slider
|
||||
menu on the stack and hands off to the
|
||||
standard menu handler
|
||||
-------------------------------------------------*/
|
||||
|
||||
UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state)
|
||||
{
|
||||
UINT32 result;
|
||||
|
||||
/* if this is the first call, push the sliders menu */
|
||||
if (state)
|
||||
ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_sliders(machine, container, true)));
|
||||
|
||||
/* handle standard menus */
|
||||
result = ui_menu::ui_handler(machine, container, state);
|
||||
|
||||
/* if we are cancelled, pop the sliders menu */
|
||||
if (result == UI_HANDLER_CANCEL)
|
||||
ui_menu::stack_pop(machine);
|
||||
|
||||
ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack);
|
||||
return uim && uim->menuless_mode ? 0 : UI_HANDLER_CANCEL;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
MENU HANDLERS
|
||||
@ -302,556 +270,6 @@ void ui_menu_bookkeeping::populate()
|
||||
item_append(tempstring, NULL, MENU_FLAG_MULTILINE, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_cheat - handle the cheat menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_cheat::handle()
|
||||
{
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(UI_MENU_PROCESS_LR_REPEAT);
|
||||
|
||||
/* handle events */
|
||||
if (menu_event != NULL && menu_event->itemref != NULL)
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
/* clear cheat comment on any movement or keypress */
|
||||
popmessage(NULL);
|
||||
|
||||
/* handle reset all + reset all cheats for reload all option */
|
||||
if ((FPTR)menu_event->itemref < 3 && menu_event->iptkey == IPT_UI_SELECT)
|
||||
{
|
||||
for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next())
|
||||
if (curcheat->select_default_state())
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
/* handle individual cheats */
|
||||
else if ((FPTR)menu_event->itemref > 2)
|
||||
{
|
||||
cheat_entry *curcheat = reinterpret_cast<cheat_entry *>(menu_event->itemref);
|
||||
const char *string;
|
||||
switch (menu_event->iptkey)
|
||||
{
|
||||
/* if selected, activate a oneshot */
|
||||
case IPT_UI_SELECT:
|
||||
changed = curcheat->activate();
|
||||
break;
|
||||
|
||||
/* if cleared, reset to default value */
|
||||
case IPT_UI_CLEAR:
|
||||
changed = curcheat->select_default_state();
|
||||
break;
|
||||
|
||||
/* left decrements */
|
||||
case IPT_UI_LEFT:
|
||||
changed = curcheat->select_previous_state();
|
||||
break;
|
||||
|
||||
/* right increments */
|
||||
case IPT_UI_RIGHT:
|
||||
changed = curcheat->select_next_state();
|
||||
break;
|
||||
|
||||
/* bring up display comment if one exists */
|
||||
case IPT_UI_DISPLAY_COMMENT:
|
||||
case IPT_UI_UP:
|
||||
case IPT_UI_DOWN:
|
||||
string = curcheat->comment();
|
||||
if (string != NULL && string[0] != 0)
|
||||
popmessage("Cheat Comment:\n%s", string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* handle reload all */
|
||||
if ((FPTR)menu_event->itemref == 2 && menu_event->iptkey == IPT_UI_SELECT)
|
||||
{
|
||||
/* re-init cheat engine and thus reload cheats/cheats have already been turned off by here */
|
||||
machine().cheat().reload();
|
||||
|
||||
/* display the reloaded cheats */
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
popmessage("All cheats reloaded");
|
||||
}
|
||||
|
||||
/* if things changed, update */
|
||||
if (changed)
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_cheat_populate - populate the cheat menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_cheat::ui_menu_cheat(running_machine &machine, render_container *container) : ui_menu(machine, container)
|
||||
{
|
||||
}
|
||||
|
||||
void ui_menu_cheat::populate()
|
||||
{
|
||||
/* iterate over cheats */
|
||||
astring text;
|
||||
astring subtext;
|
||||
for (cheat_entry *curcheat = machine().cheat().first(); curcheat != NULL; curcheat = curcheat->next())
|
||||
{
|
||||
UINT32 flags;
|
||||
curcheat->menu_text(text, subtext, flags);
|
||||
item_append(text, subtext, flags, curcheat);
|
||||
}
|
||||
|
||||
/* add a separator */
|
||||
item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
|
||||
|
||||
/* add a reset all option */
|
||||
item_append("Reset All", NULL, 0, (void *)1);
|
||||
|
||||
/* add a reload all cheats option */
|
||||
item_append("Reload All", NULL, 0, (void *)2);
|
||||
}
|
||||
|
||||
ui_menu_cheat::~ui_menu_cheat()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_sliders - handle the sliders menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_sliders::handle()
|
||||
{
|
||||
const ui_menu_event *menu_event;
|
||||
|
||||
/* process the menu */
|
||||
menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0));
|
||||
if (menu_event != NULL)
|
||||
{
|
||||
/* handle keys if there is a valid item selected */
|
||||
if (menu_event->itemref != NULL)
|
||||
{
|
||||
const slider_state *slider = (const slider_state *)menu_event->itemref;
|
||||
INT32 curvalue = (*slider->update)(machine(), slider->arg, NULL, SLIDER_NOCHANGE);
|
||||
INT32 increment = 0;
|
||||
|
||||
switch (menu_event->iptkey)
|
||||
{
|
||||
/* toggle visibility */
|
||||
case IPT_UI_ON_SCREEN_DISPLAY:
|
||||
if (menuless_mode)
|
||||
ui_menu::stack_pop(machine());
|
||||
else
|
||||
hidden = !hidden;
|
||||
break;
|
||||
|
||||
/* decrease value */
|
||||
case IPT_UI_LEFT:
|
||||
if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT))
|
||||
increment = -1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT))
|
||||
increment = (slider->incval > 10) ? -(slider->incval / 10) : -1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL))
|
||||
increment = -slider->incval * 10;
|
||||
else
|
||||
increment = -slider->incval;
|
||||
break;
|
||||
|
||||
/* increase value */
|
||||
case IPT_UI_RIGHT:
|
||||
if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT))
|
||||
increment = 1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT))
|
||||
increment = (slider->incval > 10) ? (slider->incval / 10) : 1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL))
|
||||
increment = slider->incval * 10;
|
||||
else
|
||||
increment = slider->incval;
|
||||
break;
|
||||
|
||||
/* restore default */
|
||||
case IPT_UI_SELECT:
|
||||
increment = slider->defval - curvalue;
|
||||
break;
|
||||
}
|
||||
|
||||
/* handle any changes */
|
||||
if (increment != 0)
|
||||
{
|
||||
INT32 newvalue = curvalue + increment;
|
||||
|
||||
/* clamp within bounds */
|
||||
if (newvalue < slider->minval)
|
||||
newvalue = slider->minval;
|
||||
if (newvalue > slider->maxval)
|
||||
newvalue = slider->maxval;
|
||||
|
||||
/* update the slider and recompute the menu */
|
||||
(*slider->update)(machine(), slider->arg, NULL, newvalue);
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we are selecting an invalid item and we are hidden, skip to the next one */
|
||||
else if (hidden)
|
||||
{
|
||||
/* if we got here via up or page up, select the previous item */
|
||||
if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP)
|
||||
{
|
||||
selected = (selected + numitems - 1) % numitems;
|
||||
validate_selection(-1);
|
||||
}
|
||||
|
||||
/* otherwise select the next item */
|
||||
else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN)
|
||||
{
|
||||
selected = (selected + 1) % numitems;
|
||||
validate_selection(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_sliders_populate - populate the sliders
|
||||
menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_sliders::ui_menu_sliders(running_machine &machine, render_container *container, bool _menuless_mode) : ui_menu(machine, container)
|
||||
{
|
||||
menuless_mode = hidden = _menuless_mode;
|
||||
}
|
||||
|
||||
void ui_menu_sliders::populate()
|
||||
{
|
||||
const slider_state *curslider;
|
||||
astring tempstring;
|
||||
|
||||
/* add all sliders */
|
||||
for (curslider = machine().ui().get_slider_list(); curslider != NULL; curslider = curslider->next)
|
||||
{
|
||||
INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
custombottom = 2.0f * machine().ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
|
||||
}
|
||||
|
||||
ui_menu_sliders::~ui_menu_sliders()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_sliders_custom_render - perform our special
|
||||
rendering
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
const slider_state *curslider = (const slider_state *)selectedref;
|
||||
if (curslider != NULL)
|
||||
{
|
||||
float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x;
|
||||
float line_height = machine().ui().get_line_height();
|
||||
float percentage, default_percentage;
|
||||
astring tempstring;
|
||||
float text_height;
|
||||
INT32 curval;
|
||||
|
||||
/* determine the current value and text */
|
||||
curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE);
|
||||
|
||||
/* compute the current and default percentages */
|
||||
percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
|
||||
default_percentage = (float)(curslider->defval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
|
||||
|
||||
/* assemble the text */
|
||||
tempstring.ins(0, " ").ins(0, curslider->description);
|
||||
|
||||
/* move us to the bottom of the screen, and expand to full width */
|
||||
y2 = 1.0f - UI_BOX_TB_BORDER;
|
||||
y1 = y2 - bottom;
|
||||
x1 = UI_BOX_LR_BORDER;
|
||||
x2 = 1.0f - UI_BOX_LR_BORDER;
|
||||
|
||||
/* draw extra menu area */
|
||||
machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
|
||||
y1 += UI_BOX_TB_BORDER;
|
||||
|
||||
/* determine the text height */
|
||||
machine().ui().draw_text_full(container, tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
|
||||
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height);
|
||||
|
||||
/* draw the thermometer */
|
||||
bar_left = x1 + UI_BOX_LR_BORDER;
|
||||
bar_area_top = y1;
|
||||
bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER;
|
||||
bar_area_height = line_height;
|
||||
|
||||
/* compute positions */
|
||||
bar_top = bar_area_top + 0.125f * bar_area_height;
|
||||
bar_bottom = bar_area_top + 0.875f * bar_area_height;
|
||||
default_x = bar_left + bar_width * default_percentage;
|
||||
current_x = bar_left + bar_width * percentage;
|
||||
|
||||
/* fill in the percentage */
|
||||
container->add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
/* draw the top and bottom lines */
|
||||
container->add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
container->add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
/* draw default marker */
|
||||
container->add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
container->add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
/* draw the actual text */
|
||||
machine().ui().draw_text_full(container, tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
|
||||
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_targets - handle the video targets
|
||||
menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_video_targets::handle()
|
||||
{
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(0);
|
||||
if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT)
|
||||
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, static_cast<render_target *>(menu_event->itemref))));
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_targets_populate - populate the
|
||||
video targets menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container)
|
||||
{
|
||||
}
|
||||
|
||||
void ui_menu_video_targets::populate()
|
||||
{
|
||||
int targetnum;
|
||||
|
||||
/* find the targets */
|
||||
for (targetnum = 0; ; targetnum++)
|
||||
{
|
||||
render_target *target = machine().render().target_by_index(targetnum);
|
||||
char buffer[40];
|
||||
|
||||
/* stop when we run out */
|
||||
if (target == NULL)
|
||||
break;
|
||||
|
||||
/* add a menu item */
|
||||
sprintf(buffer, "Screen #%d", targetnum);
|
||||
item_append(buffer, NULL, 0, target);
|
||||
}
|
||||
}
|
||||
|
||||
ui_menu_video_targets::~ui_menu_video_targets()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_options - handle the video options
|
||||
menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_video_options::handle()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(0);
|
||||
if (menu_event != NULL && menu_event->itemref != NULL)
|
||||
{
|
||||
switch ((FPTR)menu_event->itemref)
|
||||
{
|
||||
/* rotate adds rotation depending on the direction */
|
||||
case VIDEO_ITEM_ROTATE:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90;
|
||||
target->set_orientation(orientation_add(delta, target->orientation()));
|
||||
if (target->is_ui_target())
|
||||
{
|
||||
render_container::user_settings settings;
|
||||
container->get_user_settings(settings);
|
||||
settings.m_orientation = orientation_add(delta ^ ROT180, settings.m_orientation);
|
||||
container->set_user_settings(settings);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* layer config bitmasks handle left/right keys the same (toggle) */
|
||||
case VIDEO_ITEM_BACKDROPS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_backdrops_enabled(!target->backdrops_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_OVERLAYS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_overlays_enabled(!target->overlays_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_BEZELS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_bezels_enabled(!target->bezels_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_CPANELS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_cpanels_enabled(!target->cpanels_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_MARQUEES:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_marquees_enabled(!target->marquees_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_ZOOM:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_zoom_to_screen(!target->zoom_to_screen());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* anything else is a view item */
|
||||
default:
|
||||
if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW)
|
||||
{
|
||||
target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW);
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if something changed, rebuild the menu */
|
||||
if (changed)
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_options_populate - populate the
|
||||
video options menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_video_options::ui_menu_video_options(running_machine &machine, render_container *container, render_target *_target) : ui_menu(machine, container)
|
||||
{
|
||||
target = _target;
|
||||
}
|
||||
|
||||
void ui_menu_video_options::populate()
|
||||
{
|
||||
const char *subtext = "";
|
||||
astring tempstring;
|
||||
int viewnum;
|
||||
int enabled;
|
||||
|
||||
/* add items for each view */
|
||||
for (viewnum = 0; ; viewnum++)
|
||||
{
|
||||
const char *name = target->view_name(viewnum);
|
||||
if (name == NULL)
|
||||
break;
|
||||
|
||||
/* create a string for the item, replacing underscores with spaces */
|
||||
tempstring.cpy(name).replace(0, "_", " ");
|
||||
item_append(tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum));
|
||||
}
|
||||
|
||||
/* add a separator */
|
||||
item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
|
||||
|
||||
/* add a rotate item */
|
||||
switch (target->orientation())
|
||||
{
|
||||
case ROT0: subtext = "None"; break;
|
||||
case ROT90: subtext = "CW 90" UTF8_DEGREES; break;
|
||||
case ROT180: subtext = "180" UTF8_DEGREES; break;
|
||||
case ROT270: subtext = "CCW 90" UTF8_DEGREES; break;
|
||||
}
|
||||
item_append("Rotate", subtext, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE);
|
||||
|
||||
/* backdrop item */
|
||||
enabled = target->backdrops_enabled();
|
||||
item_append("Backdrops", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS);
|
||||
|
||||
/* overlay item */
|
||||
enabled = target->overlays_enabled();
|
||||
item_append("Overlays", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS);
|
||||
|
||||
/* bezel item */
|
||||
enabled = target->bezels_enabled();
|
||||
item_append("Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS);
|
||||
|
||||
/* cpanel item */
|
||||
enabled = target->cpanels_enabled();
|
||||
item_append("CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS);
|
||||
|
||||
/* marquee item */
|
||||
enabled = target->marquees_enabled();
|
||||
item_append("Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES);
|
||||
|
||||
/* cropping */
|
||||
enabled = target->zoom_to_screen();
|
||||
item_append("View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM);
|
||||
}
|
||||
|
||||
ui_menu_video_options::~ui_menu_video_options()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_crosshair - handle the crosshair settings
|
||||
menu
|
||||
|
@ -14,8 +14,8 @@
|
||||
#ifndef __UI_MISCMENU_H__
|
||||
#define __UI_MISCMENU_H__
|
||||
|
||||
#include "crsshair.h"
|
||||
#include "drivenum.h"
|
||||
#include "crsshair.h"
|
||||
|
||||
class ui_menu_keyboard_mode : public ui_menu {
|
||||
public:
|
||||
@ -44,59 +44,6 @@ private:
|
||||
attotime prevtime;
|
||||
};
|
||||
|
||||
class ui_menu_cheat : public ui_menu {
|
||||
public:
|
||||
ui_menu_cheat(running_machine &machine, render_container *container);
|
||||
virtual ~ui_menu_cheat();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
};
|
||||
|
||||
class ui_menu_sliders : public ui_menu {
|
||||
public:
|
||||
ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false);
|
||||
virtual ~ui_menu_sliders();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
|
||||
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
|
||||
|
||||
static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state);
|
||||
|
||||
private:
|
||||
bool menuless_mode, hidden;
|
||||
};
|
||||
|
||||
class ui_menu_video_targets : public ui_menu {
|
||||
public:
|
||||
ui_menu_video_targets(running_machine &machine, render_container *container);
|
||||
virtual ~ui_menu_video_targets();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
};
|
||||
|
||||
class ui_menu_video_options : public ui_menu {
|
||||
public:
|
||||
ui_menu_video_options(running_machine &machine, render_container *container, render_target *target);
|
||||
virtual ~ui_menu_video_options();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
|
||||
private:
|
||||
enum {
|
||||
VIDEO_ITEM_ROTATE = 0x80000000,
|
||||
VIDEO_ITEM_BACKDROPS,
|
||||
VIDEO_ITEM_OVERLAYS,
|
||||
VIDEO_ITEM_BEZELS,
|
||||
VIDEO_ITEM_CPANELS,
|
||||
VIDEO_ITEM_MARQUEES,
|
||||
VIDEO_ITEM_ZOOM,
|
||||
VIDEO_ITEM_VIEW
|
||||
};
|
||||
|
||||
render_target *target;
|
||||
};
|
||||
|
||||
class ui_menu_crosshair : public ui_menu {
|
||||
public:
|
||||
ui_menu_crosshair(running_machine &machine, render_container *container);
|
||||
|
260
src/emu/ui/sliders.c
Normal file
260
src/emu/ui/sliders.c
Normal file
@ -0,0 +1,260 @@
|
||||
/*********************************************************************
|
||||
|
||||
miscmenu.c
|
||||
|
||||
Internal MAME menus for the user interface.
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
#include "osdepend.h"
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/sliders.h"
|
||||
|
||||
|
||||
ui_menu_sliders::ui_menu_sliders(running_machine &machine, render_container *container, bool _menuless_mode) : ui_menu(machine, container)
|
||||
{
|
||||
menuless_mode = hidden = _menuless_mode;
|
||||
}
|
||||
|
||||
ui_menu_sliders::~ui_menu_sliders()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_sliders - handle the sliders menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_sliders::handle()
|
||||
{
|
||||
const ui_menu_event *menu_event;
|
||||
|
||||
/* process the menu */
|
||||
menu_event = process(UI_MENU_PROCESS_LR_REPEAT | (hidden ? UI_MENU_PROCESS_CUSTOM_ONLY : 0));
|
||||
if (menu_event != NULL)
|
||||
{
|
||||
/* handle keys if there is a valid item selected */
|
||||
if (menu_event->itemref != NULL)
|
||||
{
|
||||
const slider_state *slider = (const slider_state *)menu_event->itemref;
|
||||
INT32 curvalue = (*slider->update)(machine(), slider->arg, NULL, SLIDER_NOCHANGE);
|
||||
INT32 increment = 0;
|
||||
|
||||
switch (menu_event->iptkey)
|
||||
{
|
||||
/* toggle visibility */
|
||||
case IPT_UI_ON_SCREEN_DISPLAY:
|
||||
if (menuless_mode)
|
||||
ui_menu::stack_pop(machine());
|
||||
else
|
||||
hidden = !hidden;
|
||||
break;
|
||||
|
||||
/* decrease value */
|
||||
case IPT_UI_LEFT:
|
||||
if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT))
|
||||
increment = -1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT))
|
||||
increment = (slider->incval > 10) ? -(slider->incval / 10) : -1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL))
|
||||
increment = -slider->incval * 10;
|
||||
else
|
||||
increment = -slider->incval;
|
||||
break;
|
||||
|
||||
/* increase value */
|
||||
case IPT_UI_RIGHT:
|
||||
if (machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT))
|
||||
increment = 1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT))
|
||||
increment = (slider->incval > 10) ? (slider->incval / 10) : 1;
|
||||
else if (machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL))
|
||||
increment = slider->incval * 10;
|
||||
else
|
||||
increment = slider->incval;
|
||||
break;
|
||||
|
||||
/* restore default */
|
||||
case IPT_UI_SELECT:
|
||||
increment = slider->defval - curvalue;
|
||||
break;
|
||||
}
|
||||
|
||||
/* handle any changes */
|
||||
if (increment != 0)
|
||||
{
|
||||
INT32 newvalue = curvalue + increment;
|
||||
|
||||
/* clamp within bounds */
|
||||
if (newvalue < slider->minval)
|
||||
newvalue = slider->minval;
|
||||
if (newvalue > slider->maxval)
|
||||
newvalue = slider->maxval;
|
||||
|
||||
/* update the slider and recompute the menu */
|
||||
(*slider->update)(machine(), slider->arg, NULL, newvalue);
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we are selecting an invalid item and we are hidden, skip to the next one */
|
||||
else if (hidden)
|
||||
{
|
||||
/* if we got here via up or page up, select the previous item */
|
||||
if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP)
|
||||
{
|
||||
selected = (selected + numitems - 1) % numitems;
|
||||
validate_selection(-1);
|
||||
}
|
||||
|
||||
/* otherwise select the next item */
|
||||
else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN)
|
||||
{
|
||||
selected = (selected + 1) % numitems;
|
||||
validate_selection(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_sliders_populate - populate the sliders
|
||||
menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_sliders::populate()
|
||||
{
|
||||
const slider_state *curslider;
|
||||
astring tempstring;
|
||||
|
||||
/* add all sliders */
|
||||
for (curslider = machine().ui().get_slider_list(); curslider != NULL; curslider = curslider->next)
|
||||
{
|
||||
INT32 curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
custombottom = 2.0f * machine().ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_sliders_custom_render - perform our special
|
||||
rendering
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_sliders::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
|
||||
{
|
||||
const slider_state *curslider = (const slider_state *)selectedref;
|
||||
if (curslider != NULL)
|
||||
{
|
||||
float bar_left, bar_area_top, bar_width, bar_area_height, bar_top, bar_bottom, default_x, current_x;
|
||||
float line_height = machine().ui().get_line_height();
|
||||
float percentage, default_percentage;
|
||||
astring tempstring;
|
||||
float text_height;
|
||||
INT32 curval;
|
||||
|
||||
/* determine the current value and text */
|
||||
curval = (*curslider->update)(machine(), curslider->arg, &tempstring, SLIDER_NOCHANGE);
|
||||
|
||||
/* compute the current and default percentages */
|
||||
percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
|
||||
default_percentage = (float)(curslider->defval - curslider->minval) / (float)(curslider->maxval - curslider->minval);
|
||||
|
||||
/* assemble the text */
|
||||
tempstring.ins(0, " ").ins(0, curslider->description);
|
||||
|
||||
/* move us to the bottom of the screen, and expand to full width */
|
||||
y2 = 1.0f - UI_BOX_TB_BORDER;
|
||||
y1 = y2 - bottom;
|
||||
x1 = UI_BOX_LR_BORDER;
|
||||
x2 = 1.0f - UI_BOX_LR_BORDER;
|
||||
|
||||
/* draw extra menu area */
|
||||
machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);
|
||||
y1 += UI_BOX_TB_BORDER;
|
||||
|
||||
/* determine the text height */
|
||||
machine().ui().draw_text_full(container, tempstring, 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
|
||||
JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, NULL, &text_height);
|
||||
|
||||
/* draw the thermometer */
|
||||
bar_left = x1 + UI_BOX_LR_BORDER;
|
||||
bar_area_top = y1;
|
||||
bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER;
|
||||
bar_area_height = line_height;
|
||||
|
||||
/* compute positions */
|
||||
bar_top = bar_area_top + 0.125f * bar_area_height;
|
||||
bar_bottom = bar_area_top + 0.875f * bar_area_height;
|
||||
default_x = bar_left + bar_width * default_percentage;
|
||||
current_x = bar_left + bar_width * percentage;
|
||||
|
||||
/* fill in the percentage */
|
||||
container->add_rect(bar_left, bar_top, current_x, bar_bottom, UI_SLIDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
/* draw the top and bottom lines */
|
||||
container->add_line(bar_left, bar_top, bar_left + bar_width, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
container->add_line(bar_left, bar_bottom, bar_left + bar_width, bar_bottom, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
/* draw default marker */
|
||||
container->add_line(default_x, bar_area_top, default_x, bar_top, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
container->add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
|
||||
|
||||
/* draw the actual text */
|
||||
machine().ui().draw_text_full(container, tempstring, x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
|
||||
JUSTIFY_CENTER, WRAP_WORD, DRAW_NORMAL, UI_TEXT_COLOR, UI_TEXT_BG_COLOR, NULL, &text_height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
ui_slider_ui_handler - pushes the slider
|
||||
menu on the stack and hands off to the
|
||||
standard menu handler
|
||||
-------------------------------------------------*/
|
||||
|
||||
UINT32 ui_menu_sliders::ui_handler(running_machine &machine, render_container *container, UINT32 state)
|
||||
{
|
||||
UINT32 result;
|
||||
|
||||
/* if this is the first call, push the sliders menu */
|
||||
if (state)
|
||||
ui_menu::stack_push(auto_alloc_clear(machine, ui_menu_sliders(machine, container, true)));
|
||||
|
||||
/* handle standard menus */
|
||||
result = ui_menu::ui_handler(machine, container, state);
|
||||
|
||||
/* if we are cancelled, pop the sliders menu */
|
||||
if (result == UI_HANDLER_CANCEL)
|
||||
ui_menu::stack_pop(machine);
|
||||
|
||||
ui_menu_sliders *uim = dynamic_cast<ui_menu_sliders *>(menu_stack);
|
||||
return uim && uim->menuless_mode ? 0 : UI_HANDLER_CANCEL;
|
||||
}
|
33
src/emu/ui/sliders.h
Normal file
33
src/emu/ui/sliders.h
Normal file
@ -0,0 +1,33 @@
|
||||
/***************************************************************************
|
||||
|
||||
ui/miscmenu.h
|
||||
|
||||
Internal MAME menus for the user interface.
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UI_SLIDERS_H__
|
||||
#define __UI_SLIDERS_H__
|
||||
|
||||
class ui_menu_sliders : public ui_menu {
|
||||
public:
|
||||
ui_menu_sliders(running_machine &machine, render_container *container, bool menuless_mode = false);
|
||||
virtual ~ui_menu_sliders();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
|
||||
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2);
|
||||
|
||||
static UINT32 ui_handler(running_machine &machine, render_container *container, UINT32 state);
|
||||
|
||||
private:
|
||||
bool menuless_mode, hidden;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __UI_SLIDERS_H__ */
|
@ -16,14 +16,15 @@
|
||||
#include "render.h"
|
||||
#include "cheat.h"
|
||||
#include "rendfont.h"
|
||||
#include "ui/ui.h"
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/cheatopt.h"
|
||||
#include "ui/mainmenu.h"
|
||||
#include "ui/miscmenu.h"
|
||||
#include "ui/filemngr.h"
|
||||
#include "ui/sliders.h"
|
||||
#include "ui/viewgfx.h"
|
||||
#include "imagedev/cassette.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
233
src/emu/ui/videoopt.c
Normal file
233
src/emu/ui/videoopt.c
Normal file
@ -0,0 +1,233 @@
|
||||
/*********************************************************************
|
||||
|
||||
ui/videoopt.c
|
||||
|
||||
Internal menus for video options
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "rendutil.h"
|
||||
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/videoopt.h"
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_targets - handle the video targets
|
||||
menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_video_targets::handle()
|
||||
{
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(0);
|
||||
if (menu_event != NULL && menu_event->iptkey == IPT_UI_SELECT)
|
||||
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_video_options(machine(), container, static_cast<render_target *>(menu_event->itemref))));
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_targets_populate - populate the
|
||||
video targets menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_video_targets::ui_menu_video_targets(running_machine &machine, render_container *container) : ui_menu(machine, container)
|
||||
{
|
||||
}
|
||||
|
||||
void ui_menu_video_targets::populate()
|
||||
{
|
||||
int targetnum;
|
||||
|
||||
/* find the targets */
|
||||
for (targetnum = 0; ; targetnum++)
|
||||
{
|
||||
render_target *target = machine().render().target_by_index(targetnum);
|
||||
char buffer[40];
|
||||
|
||||
/* stop when we run out */
|
||||
if (target == NULL)
|
||||
break;
|
||||
|
||||
/* add a menu item */
|
||||
sprintf(buffer, "Screen #%d", targetnum);
|
||||
item_append(buffer, NULL, 0, target);
|
||||
}
|
||||
}
|
||||
|
||||
ui_menu_video_targets::~ui_menu_video_targets()
|
||||
{
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_options - handle the video options
|
||||
menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
void ui_menu_video_options::handle()
|
||||
{
|
||||
bool changed = false;
|
||||
|
||||
/* process the menu */
|
||||
const ui_menu_event *menu_event = process(0);
|
||||
if (menu_event != NULL && menu_event->itemref != NULL)
|
||||
{
|
||||
switch ((FPTR)menu_event->itemref)
|
||||
{
|
||||
/* rotate adds rotation depending on the direction */
|
||||
case VIDEO_ITEM_ROTATE:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
int delta = (menu_event->iptkey == IPT_UI_LEFT) ? ROT270 : ROT90;
|
||||
target->set_orientation(orientation_add(delta, target->orientation()));
|
||||
if (target->is_ui_target())
|
||||
{
|
||||
render_container::user_settings settings;
|
||||
container->get_user_settings(settings);
|
||||
settings.m_orientation = orientation_add(delta ^ ROT180, settings.m_orientation);
|
||||
container->set_user_settings(settings);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* layer config bitmasks handle left/right keys the same (toggle) */
|
||||
case VIDEO_ITEM_BACKDROPS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_backdrops_enabled(!target->backdrops_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_OVERLAYS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_overlays_enabled(!target->overlays_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_BEZELS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_bezels_enabled(!target->bezels_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_CPANELS:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_cpanels_enabled(!target->cpanels_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_MARQUEES:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_marquees_enabled(!target->marquees_enabled());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIDEO_ITEM_ZOOM:
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
target->set_zoom_to_screen(!target->zoom_to_screen());
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
/* anything else is a view item */
|
||||
default:
|
||||
if (menu_event->iptkey == IPT_UI_SELECT && (int)(FPTR)menu_event->itemref >= VIDEO_ITEM_VIEW)
|
||||
{
|
||||
target->set_view((FPTR)menu_event->itemref - VIDEO_ITEM_VIEW);
|
||||
changed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if something changed, rebuild the menu */
|
||||
if (changed)
|
||||
reset(UI_MENU_RESET_REMEMBER_REF);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
menu_video_options_populate - populate the
|
||||
video options menu
|
||||
-------------------------------------------------*/
|
||||
|
||||
ui_menu_video_options::ui_menu_video_options(running_machine &machine, render_container *container, render_target *_target) : ui_menu(machine, container)
|
||||
{
|
||||
target = _target;
|
||||
}
|
||||
|
||||
void ui_menu_video_options::populate()
|
||||
{
|
||||
const char *subtext = "";
|
||||
astring tempstring;
|
||||
int viewnum;
|
||||
int enabled;
|
||||
|
||||
/* add items for each view */
|
||||
for (viewnum = 0; ; viewnum++)
|
||||
{
|
||||
const char *name = target->view_name(viewnum);
|
||||
if (name == NULL)
|
||||
break;
|
||||
|
||||
/* create a string for the item, replacing underscores with spaces */
|
||||
tempstring.cpy(name).replace(0, "_", " ");
|
||||
item_append(tempstring, NULL, 0, (void *)(FPTR)(VIDEO_ITEM_VIEW + viewnum));
|
||||
}
|
||||
|
||||
/* add a separator */
|
||||
item_append(MENU_SEPARATOR_ITEM, NULL, 0, NULL);
|
||||
|
||||
/* add a rotate item */
|
||||
switch (target->orientation())
|
||||
{
|
||||
case ROT0: subtext = "None"; break;
|
||||
case ROT90: subtext = "CW 90" UTF8_DEGREES; break;
|
||||
case ROT180: subtext = "180" UTF8_DEGREES; break;
|
||||
case ROT270: subtext = "CCW 90" UTF8_DEGREES; break;
|
||||
}
|
||||
item_append("Rotate", subtext, MENU_FLAG_LEFT_ARROW | MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_ROTATE);
|
||||
|
||||
/* backdrop item */
|
||||
enabled = target->backdrops_enabled();
|
||||
item_append("Backdrops", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BACKDROPS);
|
||||
|
||||
/* overlay item */
|
||||
enabled = target->overlays_enabled();
|
||||
item_append("Overlays", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_OVERLAYS);
|
||||
|
||||
/* bezel item */
|
||||
enabled = target->bezels_enabled();
|
||||
item_append("Bezels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_BEZELS);
|
||||
|
||||
/* cpanel item */
|
||||
enabled = target->cpanels_enabled();
|
||||
item_append("CPanels", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_CPANELS);
|
||||
|
||||
/* marquee item */
|
||||
enabled = target->marquees_enabled();
|
||||
item_append("Marquees", enabled ? "Enabled" : "Disabled", enabled ? MENU_FLAG_LEFT_ARROW : MENU_FLAG_RIGHT_ARROW, (void *)VIDEO_ITEM_MARQUEES);
|
||||
|
||||
/* cropping */
|
||||
enabled = target->zoom_to_screen();
|
||||
item_append("View", enabled ? "Cropped" : "Full", enabled ? MENU_FLAG_RIGHT_ARROW : MENU_FLAG_LEFT_ARROW, (void *)VIDEO_ITEM_ZOOM);
|
||||
}
|
||||
|
||||
ui_menu_video_options::~ui_menu_video_options()
|
||||
{
|
||||
}
|
49
src/emu/ui/videoopt.h
Normal file
49
src/emu/ui/videoopt.h
Normal file
@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
|
||||
ui/videoopt.h
|
||||
|
||||
Internal menus for video options
|
||||
|
||||
Copyright Nicola Salmoria and the MAME Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UI_VIDEOOPT_H__
|
||||
#define __UI_VIDEOOPT_H__
|
||||
|
||||
|
||||
class ui_menu_video_targets : public ui_menu {
|
||||
public:
|
||||
ui_menu_video_targets(running_machine &machine, render_container *container);
|
||||
virtual ~ui_menu_video_targets();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
};
|
||||
|
||||
class ui_menu_video_options : public ui_menu {
|
||||
public:
|
||||
ui_menu_video_options(running_machine &machine, render_container *container, render_target *target);
|
||||
virtual ~ui_menu_video_options();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
|
||||
private:
|
||||
enum {
|
||||
VIDEO_ITEM_ROTATE = 0x80000000,
|
||||
VIDEO_ITEM_BACKDROPS,
|
||||
VIDEO_ITEM_OVERLAYS,
|
||||
VIDEO_ITEM_BEZELS,
|
||||
VIDEO_ITEM_CPANELS,
|
||||
VIDEO_ITEM_MARQUEES,
|
||||
VIDEO_ITEM_ZOOM,
|
||||
VIDEO_ITEM_VIEW
|
||||
};
|
||||
|
||||
render_target *target;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __UI_VIDEOOPT_H__ */
|
Loading…
Reference in New Issue
Block a user