Example #1
0
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, GamepadPage* const eventsink)
	: wxBoxSizer(wxVERTICAL)
	, control_group(group)
{
	static_bitmap = NULL;

	wxFont m_SmallFont(7, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
	std::vector<ControllerEmu::ControlGroup::Control*>::iterator
		ci = group->controls.begin(),
		ce = group->controls.end();
	for (; ci != ce; ++ci)
	{

		wxStaticText* const label = new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*ci)->name)));

		ControlButton* const control_button = new ControlButton(parent, (*ci)->control_ref, 80);
		control_button->SetFont(m_SmallFont);

		control_buttons.push_back(control_button);

		if ((*ci)->control_ref->is_input)
		{
			control_button->SetToolTip(_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
			control_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::DetectControl, eventsink);
		}
		else
		{
			control_button->SetToolTip(_("Left/Right-click for more options.\nMiddle-click to clear."));
			control_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::ConfigControl, eventsink);
		}

		control_button->Bind(wxEVT_MIDDLE_DOWN, &GamepadPage::ClearControl, eventsink);
		control_button->Bind(wxEVT_RIGHT_UP, &GamepadPage::ConfigControl, eventsink);

		wxBoxSizer* const control_sizer = new wxBoxSizer(wxHORIZONTAL);
		control_sizer->AddStretchSpacer(1);
		control_sizer->Add(label, 0, wxCENTER | wxRIGHT, 3);
		control_sizer->Add(control_button, 0, 0, 0);

		Add(control_sizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 3);

	}

	wxMemoryDC dc;

	switch (group->type)
	{
	case GROUP_TYPE_STICK:
	case GROUP_TYPE_TILT:
	case GROUP_TYPE_CURSOR:
	case GROUP_TYPE_FORCE:
		{
			wxBitmap bitmap(64, 64);
			dc.SelectObject(bitmap);
			dc.Clear();
			static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);

			std::vector< ControllerEmu::ControlGroup::Setting* >::const_iterator
				i = group->settings.begin(),
				e = group->settings.end();

			wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
			for (; i!=e; ++i)
			{
				PadSettingSpin* setting = new PadSettingSpin(parent, *i);
				setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
				options.push_back(setting);
				szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*i)->name))));
				szr->Add(setting->wxcontrol, 0, wxLEFT, 0);
			}

			wxBoxSizer* const h_szr = new wxBoxSizer(wxHORIZONTAL);
			h_szr->Add(szr, 1, 0, 5);
			h_szr->Add(static_bitmap, 0, wxALL|wxCENTER, 3);

			Add(h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3);
		}
		break;
	case GROUP_TYPE_BUTTONS:
		{
			wxBitmap bitmap(int(12*group->controls.size()+1), 12);
			dc.SelectObject(bitmap);
			dc.Clear();
			static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);

			PadSettingSpin* const threshold_cbox = new PadSettingSpin(parent, group->settings[0]);
			threshold_cbox->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);

			threshold_cbox->wxcontrol->SetToolTip(_("Adjust the analog control pressure required to activate buttons."));

			options.push_back(threshold_cbox);

			wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
			szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(group->settings[0]->name))),
					0, wxCENTER|wxRIGHT, 3);
			szr->Add(threshold_cbox->wxcontrol, 0, wxRIGHT, 3);

			Add(szr, 0, wxALL|wxCENTER, 3);
			Add(static_bitmap, 0, wxALL|wxCENTER, 3);
		}
		break;
	case GROUP_TYPE_MIXED_TRIGGERS:
	case GROUP_TYPE_TRIGGERS:
	case GROUP_TYPE_SLIDER:
		{
			int height = (int)(12 * group->controls.size());
			int width = 64;

			if (GROUP_TYPE_MIXED_TRIGGERS == group->type)
				width = 64+12+1;

			if (GROUP_TYPE_TRIGGERS != group->type)
				height /= 2;

			wxBitmap bitmap(width, height+1);
			dc.SelectObject(bitmap);
			dc.Clear();
			static_bitmap = new wxStaticBitmap(parent, -1, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);

			std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
				i = group->settings.begin(),
				e = group->settings.end();
			for (; i!=e; ++i)
			{
				PadSettingSpin* setting = new PadSettingSpin(parent, *i);
				setting->wxcontrol->Bind(wxEVT_COMMAND_SPINCTRL_UPDATED, &GamepadPage::AdjustSetting, eventsink);
				options.push_back(setting);
				wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
				szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr((*i)->name))), 0, wxCENTER|wxRIGHT, 3);
				szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
				Add(szr, 0, wxALL|wxCENTER, 3);
			}

			Add(static_bitmap, 0, wxALL|wxCENTER, 3);
		}
		break;
	case GROUP_TYPE_EXTENSION:
		{
			PadSettingExtension* const attachments = new PadSettingExtension(parent, (ControllerEmu::Extension*)group);
			wxButton* const configure_btn = new ExtensionButton(parent, (ControllerEmu::Extension*)group);

			options.push_back(attachments);

			attachments->wxcontrol->Bind(wxEVT_COMMAND_CHOICE_SELECTED, &GamepadPage::AdjustSetting, eventsink);
			configure_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::ConfigExtension, eventsink);

			Add(attachments->wxcontrol, 0, wxTOP|wxLEFT|wxRIGHT|wxEXPAND, 3);
			Add(configure_btn, 0, wxALL|wxEXPAND, 3);
		}
		break;
	case GROUP_TYPE_UDPWII:
		{
			wxButton* const btn = new UDPConfigButton(parent, (UDPWrapper*)group);
			btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::ConfigUDPWii, eventsink);
			Add(btn, 0, wxALL|wxEXPAND, 3);
		}
		break;
	default:
		{
			//options

			std::vector<ControllerEmu::ControlGroup::Setting*>::const_iterator
				i = group->settings.begin(),
				e = group->settings.end();
			for (; i!=e; ++i)
			{
				PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, (*i)->value, (*i)->name);
				setting_cbox->wxcontrol->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &GamepadPage::AdjustSetting, eventsink);
				options.push_back(setting_cbox);

				Add(setting_cbox->wxcontrol, 0, wxALL|wxLEFT, 5);

			}
		}
		break;
	}

	dc.SelectObject(wxNullBitmap);

	//AddStretchSpacer(0);
}
Example #2
0
NetPlaySetupDiag::NetPlaySetupDiag(wxWindow* const parent, const CGameListCtrl* const game_list)
	: wxFrame(parent, wxID_ANY, NETPLAY_TITLEBAR)
	, m_game_list(game_list)
{
	IniFile inifile;
	inifile.Load(File::GetUserPath(D_CONFIG_IDX) + "Dolphin.ini");
	IniFile::Section& netplay_section = *inifile.GetOrCreateSection("NetPlay");

	wxPanel* const panel = new wxPanel(this);

	// top row
	wxStaticText* const nick_lbl = new wxStaticText(panel, wxID_ANY, _("Nickname :"));

	std::string nickname;
	netplay_section.Get("Nickname", &nickname, "Player");
	m_nickname_text = new wxTextCtrl(panel, wxID_ANY, StrToWxStr(nickname));

	wxBoxSizer* const nick_szr = new wxBoxSizer(wxHORIZONTAL);
	nick_szr->Add(nick_lbl, 0, wxCENTER);
	nick_szr->Add(m_nickname_text, 0, wxALL, 5);


	// tabs
	wxNotebook* const notebook = new wxNotebook(panel, wxID_ANY);
	wxPanel* const connect_tab = new wxPanel(notebook, wxID_ANY);
	notebook->AddPage(connect_tab, _("Connect"));
	wxPanel* const host_tab = new wxPanel(notebook, wxID_ANY);
	notebook->AddPage(host_tab, _("Host"));


	// connect tab
	{
	wxStaticText* const ip_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Address :"));

	std::string address;
	netplay_section.Get("Address", &address, "localhost");
	m_connect_ip_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(address));

	wxStaticText* const port_lbl = new wxStaticText(connect_tab, wxID_ANY, _("Port :"));

	// string? w/e
	std::string port;
	netplay_section.Get("ConnectPort", &port, "2626");
	m_connect_port_text = new wxTextCtrl(connect_tab, wxID_ANY, StrToWxStr(port));

	wxButton* const connect_btn = new wxButton(connect_tab, wxID_ANY, _("Connect"));
	connect_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnJoin, this);

	wxStaticText* const alert_lbl = new wxStaticText(connect_tab, wxID_ANY,
		_("ALERT:\n\n"
		"Netplay will only work with the following settings:\n"
		" - Enable Dual Core [OFF]\n"
		" - DSP Emulator Engine Must be the same on all computers!\n"
		" - DSP on Dedicated Thread [OFF]\n"
		" - Framelimit NOT set to [Audio]\n"
		" - Manually set the extensions for each wiimote\n"
		"\n"
		"All players should use the same Dolphin version and settings.\n"
		"All memory cards must be identical between players or disabled.\n"
		"Wiimote support is probably terrible. Don't use it.\n"
		"\n"
		"The host must have the chosen TCP port open/forwarded!\n"));

	wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
	top_szr->Add(ip_lbl, 0, wxCENTER | wxRIGHT, 5);
	top_szr->Add(m_connect_ip_text, 3);
	top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT | wxLEFT, 5);
	top_szr->Add(m_connect_port_text, 1);

	wxBoxSizer* const con_szr = new wxBoxSizer(wxVERTICAL);
	con_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5);
	con_szr->AddStretchSpacer(1);
	con_szr->Add(alert_lbl, 0, wxLEFT | wxRIGHT | wxEXPAND, 5);
	con_szr->AddStretchSpacer(1);
	con_szr->Add(connect_btn, 0, wxALL | wxALIGN_RIGHT, 5);

	connect_tab->SetSizerAndFit(con_szr);
	}

	// host tab
	{
	wxStaticText* const port_lbl = new wxStaticText(host_tab, wxID_ANY, _("Port :"));

	// string? w/e
	std::string port;
	netplay_section.Get("HostPort", &port, "2626");
	m_host_port_text = new wxTextCtrl(host_tab, wxID_ANY, StrToWxStr(port));

	wxButton* const host_btn = new wxButton(host_tab, wxID_ANY, _("Host"));
	host_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnHost, this);

	m_game_lbox = new wxListBox(host_tab, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, wxLB_SORT);
	m_game_lbox->Bind(wxEVT_LISTBOX_DCLICK, &NetPlaySetupDiag::OnHost, this);

	FillWithGameNames(m_game_lbox, *game_list);

	wxBoxSizer* const top_szr = new wxBoxSizer(wxHORIZONTAL);
	top_szr->Add(port_lbl, 0, wxCENTER | wxRIGHT, 5);
	top_szr->Add(m_host_port_text, 0);
#ifdef USE_UPNP
	m_upnp_chk = new wxCheckBox(host_tab, wxID_ANY, _("Forward port (UPnP)"));
	top_szr->Add(m_upnp_chk, 0, wxALL | wxALIGN_RIGHT, 5);
#endif

	wxBoxSizer* const host_szr = new wxBoxSizer(wxVERTICAL);
	host_szr->Add(top_szr, 0, wxALL | wxEXPAND, 5);
	host_szr->Add(m_game_lbox, 1, wxLEFT | wxRIGHT | wxEXPAND, 5);
	host_szr->Add(host_btn, 0, wxALL | wxALIGN_RIGHT, 5);

	host_tab->SetSizerAndFit(host_szr);
	}

	// bottom row
	wxButton* const quit_btn = new wxButton(panel, wxID_ANY, _("Quit"));
	quit_btn->Bind(wxEVT_BUTTON, &NetPlaySetupDiag::OnQuit, this);

	// main sizer
	wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
	main_szr->Add(nick_szr, 0, wxALL | wxALIGN_RIGHT, 5);
	main_szr->Add(notebook, 1, wxLEFT | wxRIGHT | wxEXPAND, 5);
	main_szr->Add(quit_btn, 0, wxALL | wxALIGN_RIGHT, 5);

	panel->SetSizerAndFit(main_szr);

	//wxBoxSizer* const diag_szr = new wxBoxSizer(wxVERTICAL);
	//diag_szr->Add(panel, 1, wxEXPAND);
	//SetSizerAndFit(diag_szr);

	main_szr->SetSizeHints(this);

	Center();
	Show();
}
Example #3
0
void CCodeView::OnPaint(wxPaintEvent& event)
{
	// -------------------------
	// General settings
	// -------------------------
	std::unique_ptr<wxGraphicsContext> ctx(wxGraphicsContext::Create(wxPaintDC(this)));
	wxRect rc = GetClientRect();

	ctx->SetFont(DebuggerFont, *wxBLACK);

	wxDouble w,h;
	ctx->GetTextExtent("0WJyq", &w, &h);

	if (h > m_rowHeight)
		m_rowHeight = h;

	ctx->GetTextExtent("W", &w, &h);
	int charWidth = w;

	struct branch
	{
		int src, dst, srcAddr;
	};

	branch branches[256];
	int numBranches = 0;
	// TODO: Add any drawing code here...
	int width   = rc.width;
	int numRows = ((rc.height / m_rowHeight) / 2) + 2;
	// ------------

	// -------------------------
	// Colors and brushes
	// -------------------------

	const wxColour bgColor = *wxWHITE;
	wxPen nullPen(bgColor);
	wxPen currentPen(*wxBLACK_PEN);
	wxPen selPen(*wxGREY_PEN);
	nullPen.SetStyle(wxTRANSPARENT);
	currentPen.SetStyle(wxSOLID);
	wxBrush currentBrush(*wxLIGHT_GREY_BRUSH);
	wxBrush pcBrush(*wxGREEN_BRUSH);
	wxBrush bpBrush(*wxRED_BRUSH);

	wxBrush bgBrush(bgColor);
	wxBrush nullBrush(bgColor);
	nullBrush.SetStyle(wxTRANSPARENT);

	ctx->SetPen(nullPen);
	ctx->SetBrush(bgBrush);
	ctx->DrawRectangle(0, 0, 16, rc.height);
	ctx->DrawRectangle(0, 0, rc.width, 5);
	// ------------
	m_symbol_db->PopulateSymbolComments();

	// -----------------------------
	// Walk through all visible rows
	// -----------------------------
	for (int i = -numRows; i <= numRows; i++)
	{
		unsigned int address = m_curAddress + (i * m_align);

		int rowY1 = (rc.height / 2) + (m_rowHeight * i) - (m_rowHeight / 2);
		int rowY2 = (rc.height / 2) + (m_rowHeight * i) + (m_rowHeight / 2);

		wxString temp = wxString::Format("%08x", address);
		u32 color = m_debugger->GetColor(address);
		wxBrush rowBrush(wxColour(color >> 16, color >> 8, color));
		ctx->SetBrush(nullBrush);
		ctx->SetPen(nullPen);
		ctx->DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);

		if (m_selecting && (address == m_selection))
			ctx->SetPen(selPen);
		else
			ctx->SetPen(i == 0 ? currentPen : nullPen);

		if (address == m_debugger->GetPC())
			ctx->SetBrush(pcBrush);
		else
			ctx->SetBrush(rowBrush);

		ctx->DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
		ctx->SetBrush(currentBrush);
		if (!m_plain)
		{
			// the address text is dark red
			ctx->SetFont(DebuggerFont, wxColour("#600000"));
			ctx->DrawText(temp, 17, rowY1);
			ctx->SetFont(DebuggerFont, *wxBLACK);
		}

		// If running
		if (m_debugger->IsAlive())
		{
			std::vector<std::string> dis;
			SplitString(m_debugger->Disassemble(address), '\t', dis);
			dis.resize(2);

			static const size_t VALID_BRANCH_LENGTH = 10;
			const std::string& opcode   = dis[0];
			const std::string& operands = dis[1];
			std::string desc;
			std::string comment = m_symbol_db->GetCommentFromAddress(address);

			// look for hex strings to decode branches
			std::string hex_str;
			size_t pos = operands.find("0x8");
			if (pos != std::string::npos)
			{
				hex_str = operands.substr(pos);
			}

			if (hex_str.length() == VALID_BRANCH_LENGTH)
			{
				u32 offs = std::stoul(hex_str, nullptr, 16);

				branches[numBranches].src = rowY1 + (m_rowHeight / 2);
				branches[numBranches].srcAddr = (address / m_align);
				branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * m_rowHeight / m_align + m_rowHeight / 2);
				desc = StringFromFormat("-->%s", m_debugger->GetDescription(offs).c_str());

				// the -> arrow illustrations are purple
				ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("PURPLE"));
			}
			else
			{
				ctx->SetFont(DebuggerFont, *wxBLACK);
			}

			ctx->DrawText(StrToWxStr(operands), 17 + 12*charWidth, rowY1);
			// ------------

			// Show blr as its' own color
			if (opcode == "blr")
				ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("DARK GREEN"));
			else
				ctx->SetFont(DebuggerFont, wxTheColourDatabase->Find("VIOLET"));

			ctx->DrawText(StrToWxStr(opcode), 17 + (m_plain ? 1*charWidth : 7*charWidth), rowY1);

			if (desc.empty())
			{
				desc = m_debugger->GetDescription(address);
			}

			if (!m_plain)
			{
				ctx->SetFont(DebuggerFont, *wxBLUE);

				//char temp[256];
				//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
				if (!desc.empty())
				{
					ctx->DrawText(StrToWxStr(desc), 17 + 28 * charWidth, rowY1);
				}
			}

			if (!comment.empty())
			{
				ctx->SetFont(DebuggerFont, *wxBLACK);
				ctx->DrawText(StrToWxStr(comment), 17 + 60*charWidth, rowY1);
			}

			// Show red breakpoint dot
			if (m_debugger->IsBreakpoint(address))
			{
				ctx->SetBrush(bpBrush);
				ctx->DrawRectangle(2, rowY1 + 1, 11, 11);
			}
		}
	} // end of for
	// ------------

	// -------------------------
	// Branch Arrows TODO: Add a toggle option for these in case symbol names are longer than normal
	// -------------------------
	ctx->SetPen(currentPen);

	for (int i = 0; i < numBranches; i++)
	{
		int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8;
		MoveTo(x-2, branches[i].src);

		if (branches[i].dst < rc.height + 400 && branches[i].dst > -400)
		{
			LineTo(ctx, x+2, branches[i].src);
			LineTo(ctx, x+2, branches[i].dst);
			LineTo(ctx, x-4, branches[i].dst);

			MoveTo(x, branches[i].dst - 4);
			LineTo(ctx, x-4, branches[i].dst);
			LineTo(ctx, x+1, branches[i].dst+5);
		}
		//else
		//{
			// This can be re-enabled when there is a scrollbar or
			// something on the codeview (the lines are too long)

			//LineTo(ctx, x+4, branches[i].src);
			//MoveTo(x+2, branches[i].dst-4);
			//LineTo(ctx, x+6, branches[i].dst);
			//LineTo(ctx, x+1, branches[i].dst+5);
		//}

		//LineTo(ctx, x, branches[i].dst+4);
		//LineTo(ctx, x-2, branches[i].dst);
	}
	// ------------
}
Example #4
0
void Host_UpdateTitle(const std::string& title)
{
	wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_UPDATE_TITLE);
	event.SetString(StrToWxStr(title));
	main_frame->GetEventHandler()->AddPendingEvent(event);
}
Example #5
0
NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game_list,
		const std::string& game, const bool is_hosting)
	: wxFrame(parent, wxID_ANY, NETPLAY_TITLEBAR)
	, m_selected_game(game)
	, m_start_btn(nullptr)
	, m_game_list(game_list)
{
	wxPanel* const panel = new wxPanel(this);

	// top crap
	m_game_btn = new wxButton(panel, wxID_ANY,
			StrToWxStr(m_selected_game).Prepend(_(" Game : ")),
			wxDefaultPosition, wxDefaultSize, wxBU_LEFT);

	if (is_hosting)
		m_game_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnChangeGame, this);
	else
		m_game_btn->Disable();

	// middle crap

	// chat
	m_chat_text = new wxTextCtrl(panel, wxID_ANY, wxEmptyString
		, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_MULTILINE);

	m_chat_msg_text = new wxTextCtrl(panel, wxID_ANY, wxEmptyString
		, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
	m_chat_msg_text->Bind(wxEVT_TEXT_ENTER, &NetPlayDiag::OnChat, this);
	m_chat_msg_text->SetMaxLength(2000);

	wxButton* const chat_msg_btn = new wxButton(panel, wxID_ANY, _("Send"));
	chat_msg_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnChat, this);

	wxBoxSizer* const chat_msg_szr = new wxBoxSizer(wxHORIZONTAL);
	chat_msg_szr->Add(m_chat_msg_text, 1);
	chat_msg_szr->Add(chat_msg_btn, 0);

	wxStaticBoxSizer* const chat_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Chat"));
	chat_szr->Add(m_chat_text, 1, wxEXPAND);
	chat_szr->Add(chat_msg_szr, 0, wxEXPAND | wxTOP, 5);

	m_player_lbox = new wxListBox(panel, wxID_ANY, wxDefaultPosition, wxSize(256, -1));

	wxStaticBoxSizer* const player_szr = new wxStaticBoxSizer(wxVERTICAL, panel, _("Players"));
	player_szr->Add(m_player_lbox, 1, wxEXPAND);
	// player list
	if (is_hosting)
	{
		wxButton* const player_config_btn = new wxButton(panel, wxID_ANY, _("Configure Pads"));
		player_config_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnConfigPads, this);
		player_szr->Add(player_config_btn, 0, wxEXPAND | wxTOP, 5);
	}

	wxBoxSizer* const mid_szr = new wxBoxSizer(wxHORIZONTAL);
	mid_szr->Add(chat_szr, 1, wxEXPAND | wxRIGHT, 5);
	mid_szr->Add(player_szr, 0, wxEXPAND);

	// bottom crap
	wxButton* const quit_btn = new wxButton(panel, wxID_ANY, _("Quit"));
	quit_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnQuit, this);

	wxBoxSizer* const bottom_szr = new wxBoxSizer(wxHORIZONTAL);
	if (is_hosting)
	{
		m_start_btn = new wxButton(panel, wxID_ANY, _("Start"));
		m_start_btn->Bind(wxEVT_BUTTON, &NetPlayDiag::OnStart, this);
		bottom_szr->Add(m_start_btn);

		bottom_szr->Add(new wxStaticText(panel, wxID_ANY, _("Buffer:")), 0, wxLEFT | wxCENTER, 5 );
		wxSpinCtrl* const padbuf_spin = new wxSpinCtrl(panel, wxID_ANY, "20"
			, wxDefaultPosition, wxSize(64, -1), wxSP_ARROW_KEYS, 0, 200, INITIAL_PAD_BUFFER_SIZE);
		padbuf_spin->Bind(wxEVT_SPINCTRL, &NetPlayDiag::OnAdjustBuffer, this);
		bottom_szr->Add(padbuf_spin, 0, wxCENTER);

		m_memcard_write = new wxCheckBox(panel, wxID_ANY, _("Write memcards (GC)"));
		bottom_szr->Add(m_memcard_write, 0, wxCENTER);
	}

	m_record_chkbox = new wxCheckBox(panel, wxID_ANY, _("Record input"));
	bottom_szr->Add(m_record_chkbox, 0, wxCENTER);

	bottom_szr->AddStretchSpacer(1);
	bottom_szr->Add(quit_btn);

	// main sizer
	wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
	main_szr->Add(m_game_btn, 0, wxEXPAND | wxALL, 5);
	main_szr->Add(mid_szr, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);
	main_szr->Add(bottom_szr, 0, wxEXPAND | wxALL, 5);

	panel->SetSizerAndFit(main_szr);

	main_szr->SetSizeHints(this);
	SetSize(512, 512-128);

	Center();
}
static wxString GetValueByRowCol(int row, int col)
{
	if (row < 32)
	{
		switch (col)
		{
		case 0: return StrToWxStr(GekkoDisassembler::GetGPRName(row));
		case 1: return wxString::Format("%08x", GPR(row));
		case 2: return StrToWxStr(GekkoDisassembler::GetFPRName(row));
		case 3: return wxString::Format("%016llx", riPS0(row));
		case 4: return wxString::Format("%016llx", riPS1(row));
		case 5:
		{
			if (row < 4)
				return wxString::Format("DBAT%01d", row);

			if (row < 8)
				return wxString::Format("IBAT%01d", row - 4);

			if (row < 12)
				return wxString::Format("DBAT%01d", row - 4);

			if (row < 16)
				return wxString::Format("IBAT%01d", row - 8);

			break;
		}
		case 6:
		{
			if (row < 4)
				return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_DBAT0U + row * 2] << 32 | PowerPC::ppcState.spr[SPR_DBAT0L + row * 2]);

			if (row < 8)
				return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_IBAT0U + (row - 4) * 2] << 32 | PowerPC::ppcState.spr[SPR_IBAT0L + (row - 4) * 2]);

			if (row < 12)
				return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_DBAT4U + (row - 12) * 2] << 32 | PowerPC::ppcState.spr[SPR_DBAT4L + (row - 12) * 2]);

			if (row < 16)
				return wxString::Format("%016llx", (u64)PowerPC::ppcState.spr[SPR_IBAT4U + (row - 16) * 2] << 32 | PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]);

			break;
		}
		case 7:
		{
			if (row < 16)
				return wxString::Format("SR%02d", row);

			break;
		}
		case 8:
		{
			if (row < 16)
				return wxString::Format("%08x", PowerPC::ppcState.sr[row]);

			break;
		}
		default: return wxEmptyString;
		}
	}
	else
	{
		if (row - 32 < NUM_SPECIALS)
		{
			switch (col)
			{
			case 0: return StrToWxStr(special_reg_names[row - 32]);
			case 1: return wxString::Format("%08x", GetSpecialRegValue(row - 32));
			default: return wxEmptyString;
			}
		}
	}
	return wxEmptyString;
}
Example #7
0
bool DolphinApp::OnInit()
{
    InitLanguageSupport();

    // Declarations and definitions
    bool UseDebugger = false;
    bool UseLogger = false;
    bool selectVideoBackend = false;
    bool selectAudioEmulation = false;

    wxString videoBackendName;
    wxString audioEmulationName;
    wxString userPath;

#if wxUSE_CMDLINE_PARSER // Parse command lines
    wxCmdLineEntryDesc cmdLineDesc[] =
    {
        {
            wxCMD_LINE_SWITCH, "h", "help",
            "Show this help message",
            wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
        },
        {
            wxCMD_LINE_SWITCH, "d", "debugger",
            "Opens the debugger",
            wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_SWITCH, "l", "logger",
            "Opens the logger",
            wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_OPTION, "e", "exec",
            "Loads the specified file (DOL,ELF,GCM,ISO,WAD)",
            wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_SWITCH, "b", "batch",
            "Exit Dolphin with emulator",
            wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_OPTION, "V", "video_backend",
            "Specify a video backend",
            wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_OPTION, "A", "audio_emulation",
            "Low level (LLE) or high level (HLE) audio",
            wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_OPTION, "m", "movie",
            "Play a movie file",
            wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_OPTION, "U", "user",
            "User folder path",
            wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL
        },
        {
            wxCMD_LINE_NONE, nullptr, nullptr, nullptr, wxCMD_LINE_VAL_NONE, 0
        }
    };

    // Gets the command line parameters
    wxCmdLineParser parser(cmdLineDesc, argc, argv);
    if (parser.Parse() != 0)
    {
        return false;
    }

    UseDebugger = parser.Found(wxT("debugger"));
    UseLogger = parser.Found(wxT("logger"));
    LoadFile = parser.Found(wxT("exec"), &FileToLoad);
    BatchMode = parser.Found(wxT("batch"));
    selectVideoBackend = parser.Found(wxT("video_backend"),
                                      &videoBackendName);
    selectAudioEmulation = parser.Found(wxT("audio_emulation"),
                                        &audioEmulationName);
    playMovie = parser.Found(wxT("movie"), &movieFile);

    if (parser.Found(wxT("user"), &userPath))
    {
        File::CreateFullPath(WxStrToStr(userPath) + DIR_SEP);
        File::GetUserPath(D_USER_IDX, userPath.ToStdString() + DIR_SEP);
    }
#endif // wxUSE_CMDLINE_PARSER

#if defined _DEBUG && defined _WIN32
    int tmpflag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    tmpflag |= _CRTDBG_DELAY_FREE_MEM_DF;
    _CrtSetDbgFlag(tmpflag);
#endif

    // Register message box and translation handlers
    RegisterMsgAlertHandler(&wxMsgAlert);
    RegisterStringTranslator(&wxStringTranslator);

    // "ExtendedTrace" looks freakin' dangerous!!!
#ifdef _WIN32
    EXTENDEDTRACEINITIALIZE(".");
    SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter);
#elif wxUSE_ON_FATAL_EXCEPTION
    wxHandleFatalExceptions(true);
#endif

#ifndef _M_ARM
    // TODO: if First Boot
    if (!cpu_info.bSSE2)
    {
        PanicAlertT("Hi,\n\nDolphin requires that your CPU has support for SSE2 extensions.\n"
                    "Unfortunately your CPU does not support them, so Dolphin will not run.\n\n"
                    "Sayonara!\n");
        return false;
    }
#endif
#ifdef __APPLE__
    if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_7)
    {
        PanicAlertT("Hi,\n\nDolphin requires Mac OS X 10.7 or greater.\n"
                    "Unfortunately you're running an old version of OS X.\n"
                    "The last Dolphin version to support OS X 10.6 is Dolphin 3.5\n"
                    "Please upgrade to 10.7 or greater to use the newest Dolphin version.\n\n"
                    "Sayonara!\n");
        return false;
    }
#endif

    // Copy initial Wii NAND data from Sys to User.
    File::CopyDir(File::GetSysDirectory() + WII_USER_DIR DIR_SEP,
                  File::GetUserPath(D_WIIUSER_IDX));

    File::CreateFullPath(File::GetUserPath(D_USER_IDX));
    File::CreateFullPath(File::GetUserPath(D_CACHE_IDX));
    File::CreateFullPath(File::GetUserPath(D_CONFIG_IDX));
    File::CreateFullPath(File::GetUserPath(D_DUMPDSP_IDX));
    File::CreateFullPath(File::GetUserPath(D_DUMPTEXTURES_IDX));
    File::CreateFullPath(File::GetUserPath(D_GAMESETTINGS_IDX));
    File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX));
    File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + USA_DIR DIR_SEP);
    File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + EUR_DIR DIR_SEP);
    File::CreateFullPath(File::GetUserPath(D_GCUSER_IDX) + JAP_DIR DIR_SEP);
    File::CreateFullPath(File::GetUserPath(D_HIRESTEXTURES_IDX));
    File::CreateFullPath(File::GetUserPath(D_MAILLOGS_IDX));
    File::CreateFullPath(File::GetUserPath(D_MAPS_IDX));
    File::CreateFullPath(File::GetUserPath(D_SCREENSHOTS_IDX));
    File::CreateFullPath(File::GetUserPath(D_SHADERS_IDX));
    File::CreateFullPath(File::GetUserPath(D_STATESAVES_IDX));
    File::CreateFullPath(File::GetUserPath(D_THEMES_IDX));

    LogManager::Init();
    SConfig::Init();
    VideoBackend::PopulateList();
    WiimoteReal::LoadSettings();

    if (selectVideoBackend && videoBackendName != wxEmptyString)
        SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend =
            WxStrToStr(videoBackendName);

    if (selectAudioEmulation)
    {
        if (audioEmulationName == "HLE")
            SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = true;
        else if (audioEmulationName == "LLE")
            SConfig::GetInstance().m_LocalCoreStartupParameter.bDSPHLE = false;
    }

    VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoBackend);

    // Enable the PNG image handler for screenshots
    wxImage::AddHandler(new wxPNGHandler);

    SetEnableAlert(SConfig::GetInstance().m_LocalCoreStartupParameter.bUsePanicHandlers);

    int x = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosX;
    int y = SConfig::GetInstance().m_LocalCoreStartupParameter.iPosY;
    int w = SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth;
    int h = SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight;

#ifdef _WIN32
    if (File::Exists("www.dolphin-emulator.com.txt"))
    {
        File::Delete("www.dolphin-emulator.com.txt");
        MessageBox(nullptr,
                   L"This version of Dolphin was downloaded from a website stealing money from developers of the emulator. Please "
                   L"download Dolphin from the official website instead: http://dolphin-emu.org/",
                   L"Unofficial version detected", MB_OK | MB_ICONWARNING);
        ShellExecute(nullptr, L"open", L"http://dolphin-emu.org/?ref=badver", nullptr, nullptr, SW_SHOWDEFAULT);
        exit(0);
    }
#endif

    // The following is not needed with X11, where window managers
    // do not allow windows to be created off the desktop.
#ifdef _WIN32
    // Out of desktop check
    int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN);
    int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN);
    int width =  GetSystemMetrics(SM_CXVIRTUALSCREEN);
    int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
    if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y)
        x = y = wxDefaultCoord;
#elif defined __APPLE__
    if (y < 1)
        y = wxDefaultCoord;
#endif

    main_frame = new CFrame((wxFrame*)nullptr, wxID_ANY,
                            StrToWxStr(scm_rev_str),
                            wxPoint(x, y), wxSize(w, h),
                            UseDebugger, BatchMode, UseLogger);
    SetTopWindow(main_frame);
    main_frame->SetMinSize(wxSize(400, 300));

    // Postpone final actions until event handler is running.
    // Updating the game list makes use of wxProgressDialog which may
    // only be run after OnInit() when the event handler is running.
    m_afterinit = new wxTimer(this, wxID_ANY);
    m_afterinit->Start(1, wxTIMER_ONE_SHOT);

    return true;
}
Example #8
0
void CGameListCtrl::ScanForISOs()
{
	ClearIsoFiles();

	CFileSearch::XStringVector Directories(SConfig::GetInstance().m_ISOFolder);

	if (SConfig::GetInstance().m_RecursiveISOFolder)
	{
		for (u32 i = 0; i < Directories.size(); i++)
		{
			File::FSTEntry FST_Temp;
			File::ScanDirectoryTree(Directories[i], FST_Temp);
			for (u32 j = 0; j < FST_Temp.children.size(); j++)
			{
				if (FST_Temp.children[j].isDirectory)
				{
					bool duplicate = false;
					for (u32 k = 0; k < Directories.size(); k++)
					{
						if (strcmp(Directories[k].c_str(),
									FST_Temp.children[j].physicalName.c_str()) == 0)
						{
							duplicate = true;
							break;
						}
					}
					if (!duplicate)
						Directories.push_back(
								FST_Temp.children[j].physicalName.c_str());
				}
			}
		}
	}

	CFileSearch::XStringVector Extensions;

	if (SConfig::GetInstance().m_ListGC)
		Extensions.push_back("*.gcm");
	if (SConfig::GetInstance().m_ListWii || SConfig::GetInstance().m_ListGC)
	{
		Extensions.push_back("*.iso");
		Extensions.push_back("*.ciso");
		Extensions.push_back("*.gcz");
		Extensions.push_back("*.wbfs");
	}
	if (SConfig::GetInstance().m_ListWad)
		Extensions.push_back("*.wad");

	CFileSearch FileSearch(Extensions, Directories);
	const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();

	if (rFilenames.size() > 0)
	{
		wxProgressDialog dialog(
			_("Scanning for ISOs"),
			_("Scanning..."),
			(int)rFilenames.size() - 1,
			this,
			wxPD_APP_MODAL |
			wxPD_AUTO_HIDE |
			wxPD_CAN_ABORT |
			wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME |
			wxPD_SMOOTH // - makes updates as small as possible (down to 1px)
			);

		for (u32 i = 0; i < rFilenames.size(); i++)
		{
			std::string FileName;
			SplitPath(rFilenames[i], NULL, &FileName, NULL);

			// Update with the progress (i) and the message
			dialog.Update(i, wxString::Format(_("Scanning %s"),
				StrToWxStr(FileName)));
			if (dialog.WasCancelled())
				break;

			std::auto_ptr<GameListItem> iso_file(new GameListItem(rFilenames[i]));
			const GameListItem& ISOFile = *iso_file;

			if (ISOFile.IsValid())
			{
				bool list = true;

				switch(ISOFile.GetPlatform())
				{
					case GameListItem::WII_DISC:
						if (!SConfig::GetInstance().m_ListWii)
							list = false;
						break;
					case GameListItem::WII_WAD:
						if (!SConfig::GetInstance().m_ListWad)
							list = false;
						break;
					default:
						if (!SConfig::GetInstance().m_ListGC)
							list = false;
						break;
				}

				switch(ISOFile.GetCountry())
				{
					case DiscIO::IVolume::COUNTRY_TAIWAN:
						if (!SConfig::GetInstance().m_ListTaiwan)
							list = false;
					case DiscIO::IVolume::COUNTRY_KOREA:
						if (!SConfig::GetInstance().m_ListKorea)
							list = false;
						break;
					case DiscIO::IVolume::COUNTRY_JAPAN:
						if (!SConfig::GetInstance().m_ListJap)
							list = false;
						break;
					case DiscIO::IVolume::COUNTRY_USA:
						if (!SConfig::GetInstance().m_ListUsa)
							list = false;
						break;
					case DiscIO::IVolume::COUNTRY_FRANCE:
						if (!SConfig::GetInstance().m_ListFrance)
							list = false;
						break;
					case DiscIO::IVolume::COUNTRY_ITALY:
						if (!SConfig::GetInstance().m_ListItaly)
							list = false;
						break;
					default:
						if (!SConfig::GetInstance().m_ListPal)
							list = false;
						break;
				}

				if (list)
					m_ISOFiles.push_back(iso_file.release());
			}
		}
	}

	if (SConfig::GetInstance().m_ListDrives)
	{
		const std::vector<std::string> drives = cdio_get_devices();

		for (std::vector<std::string>::const_iterator iter = drives.begin(); iter != drives.end(); ++iter)
		{
			#ifdef __APPLE__
			std::auto_ptr<GameListItem> gli(new GameListItem(*iter));
			#else
			std::unique_ptr<GameListItem> gli(new GameListItem(*iter));
			#endif

			if (gli->IsValid())
				m_ISOFiles.push_back(gli.release());
		}
	}

	std::sort(m_ISOFiles.begin(), m_ISOFiles.end());
}
Example #9
0
// This shows a little tooltip with the current Game's emulation state
void CGameListCtrl::OnMouseMotion(wxMouseEvent& event)
{
	int flags;
	long subitem = 0;
	const long item = HitTest(event.GetPosition(), flags, &subitem);
	static int lastItem = -1;

	if (GetColumnCount() <= 1)
		return;

	if (item != wxNOT_FOUND)
	{
		wxRect Rect;
#ifdef __WXMSW__
		if (subitem == COLUMN_EMULATION_STATE)
#else
		// The subitem parameter of HitTest is only implemented for wxMSW.  On
		// all other platforms it will always be -1.  Check the x position
		// instead.
		GetItemRect(item, Rect);
		if (Rect.GetX() + Rect.GetWidth() - GetColumnWidth(COLUMN_EMULATION_STATE) < event.GetX())
#endif
		{
			if (toolTip || lastItem == item || this != FindFocus())
			{
				if (lastItem != item) lastItem = -1;
				event.Skip();
				return;
			}

			// Emulation status
			static const char* const emuState[] = { "Broken", "Intro", "In-Game", "Playable", "Perfect" };

			const GameListItem& rISO = *m_ISOFiles[GetItemData(item)];

			const int emu_state = rISO.GetEmuState();
			const std::string& issues = rISO.GetIssues();

			// Show a tooltip containing the EmuState and the state description
			if (emu_state > 0 && emu_state < 6)
			{
				char temp[2048];
				sprintf(temp, "^ %s%s%s", emuState[emu_state - 1],
						issues.size() > 0 ? " :\n" : "", issues.c_str());
				toolTip = new wxEmuStateTip(this, StrToWxStr(temp), &toolTip);
			}
			else
			{
				toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip);
			}

			// Get item Coords
			GetItemRect(item, Rect);
			int mx = Rect.GetWidth();
			int my = Rect.GetY();
#ifndef __WXMSW__
			// For some reason the y position does not account for the header
			// row, so subtract the y position of the first visible item.
			GetItemRect(GetTopItem(), Rect);
			my -= Rect.GetY();
#endif
			// Convert to screen coordinates
			ClientToScreen(&mx, &my);
			toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(COLUMN_EMULATION_STATE),
						my, GetColumnWidth(COLUMN_EMULATION_STATE), Rect.GetHeight()));
			toolTip->SetPosition(wxPoint(mx - GetColumnWidth(COLUMN_EMULATION_STATE),
						my - 5 + Rect.GetHeight()));
			lastItem = item;
		}
	}
	if (!toolTip)
		lastItem = -1;

	event.Skip();
}
Example #10
0
void CGameListCtrl::OnCompressGCM(wxCommandEvent& WXUNUSED (event))
{
	const GameListItem *iso = GetSelectedISO();
	if (!iso)
		return;

	wxString path;

	std::string FileName, FilePath, FileExtension;
	SplitPath(iso->GetFileName(), &FilePath, &FileName, &FileExtension);

	do
	{
		if (iso->IsCompressed())
		{
			wxString FileType;
			if (iso->GetPlatform() == GameListItem::WII_DISC)
				FileType = _("All Wii ISO files (iso)") + wxString(wxT("|*.iso"));
			else
				FileType = _("All Gamecube GCM files (gcm)") + wxString(wxT("|*.gcm"));

			path = wxFileSelector(
					_("Save decompressed GCM/ISO"),
					StrToWxStr(FilePath),
					StrToWxStr(FileName) + FileType.After('*'),
					wxEmptyString,
					FileType + wxT("|") + wxGetTranslation(wxALL_FILES),
					wxFD_SAVE,
					this);
		}
		else
		{
			path = wxFileSelector(
					_("Save compressed GCM/ISO"),
					StrToWxStr(FilePath),
					StrToWxStr(FileName) + _T(".gcz"),
					wxEmptyString,
					_("All compressed GC/Wii ISO files (gcz)") + 
						wxString::Format(wxT("|*.gcz|%s"), wxGetTranslation(wxALL_FILES)),
					wxFD_SAVE,
					this);
		}
		if (!path)
			return;
	} while (wxFileExists(path) &&
			wxMessageBox(
				wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"), path.c_str()), 
				_("Confirm File Overwrite"),
				wxYES_NO) == wxNO);

	bool all_good = false;

	{
	wxProgressDialog dialog(
		iso->IsCompressed() ? _("Decompressing ISO") : _("Compressing ISO"),
		_("Working..."),
		1000,
		this,
		wxPD_APP_MODAL |
		wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME |
		wxPD_SMOOTH
		);


	if (iso->IsCompressed())
		all_good = DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
				path.char_str(), &CompressCB, &dialog);
	else
		all_good = DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
				path.char_str(),
				(iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0,
				16384, &CompressCB, &dialog);
	}

	if (!all_good)
		wxMessageBox(_("Dolphin was unable to complete the requested action."));

	Update();
}
Example #11
0
void CGameListCtrl::InsertItemInReportView(long _Index)
{
	// When using wxListCtrl, there is no hope of per-column text colors.
	// But for reference, here are the old colors that were used: (BGR)
	// title: 0xFF0000
	// company: 0x007030
	int ImageIndex = -1;

	GameListItem& rISOFile = *m_ISOFiles[_Index];

	// Insert a first row with nothing in it, that will be used as the Index
	long ItemIndex = InsertItem(_Index, wxEmptyString);

	// Insert the platform's image in the first (visible) column
	SetItemColumnImage(_Index, COLUMN_PLATFORM, m_PlatformImageIndex[rISOFile.GetPlatform()]);

	if (rISOFile.GetImage().IsOk())
		ImageIndex = m_imageListSmall->Add(rISOFile.GetImage());

	// Set the game's banner in the second column
	SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);

	int SelectedLanguage = SConfig::GetInstance().m_LocalCoreStartupParameter.SelectedLanguage;
	
	// Is this sane?
	switch (rISOFile.GetCountry())
	{
	case DiscIO::IVolume::COUNTRY_TAIWAN:
	case DiscIO::IVolume::COUNTRY_JAPAN:
		SelectedLanguage = -1;
		break;
		
	case DiscIO::IVolume::COUNTRY_USA:
		SelectedLanguage = 0;
		break;
		
	default:
		break;
	}
	
	std::string const name = rISOFile.GetName(SelectedLanguage);
	SetItem(_Index, COLUMN_TITLE, StrToWxStr(name), -1);

	// We show the company string on Gamecube only
	// On Wii we show the description instead as the company string is empty
	std::string const notes = (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) ?
		rISOFile.GetCompany() : rISOFile.GetDescription(SelectedLanguage);
	SetItem(_Index, COLUMN_NOTES, StrToWxStr(notes), -1);

	// Emulation state
	SetItemColumnImage(_Index, COLUMN_EMULATION_STATE, m_EmuStateImageIndex[rISOFile.GetEmuState()]);

	// Country
	SetItemColumnImage(_Index, COLUMN_COUNTRY, m_FlagImageIndex[rISOFile.GetCountry()]);

	// File size
	SetItem(_Index, COLUMN_SIZE, NiceSizeFormat(rISOFile.GetFileSize()), -1);

	// Background color
	SetBackgroundColor();

	// Item data
	SetItemData(_Index, ItemIndex);
}
Example #12
0
void CGameListCtrl::CompressCB(const char* text, float percent, void* arg)
{
	((wxProgressDialog*)arg)->
		Update((int)(percent*1000), StrToWxStr(text));
}
Example #13
0
void CGameListCtrl::CompressSelection(bool _compress)
{
	wxString dirHome;
	wxGetHomeDir(&dirHome);

	wxDirDialog browseDialog(this, _("Browse for output directory"), dirHome,
			wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
	if (browseDialog.ShowModal() != wxID_OK)
		return;

	bool all_good = true;

	{
	wxProgressDialog progressDialog(
		_compress ? _("Compressing ISO") : _("Decompressing ISO"),
		_("Working..."),
		1000,
		this,
		wxPD_APP_MODAL |
		wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME |
		wxPD_SMOOTH
		);

	m_currentItem = 0;
	m_numberItem = GetSelectedItemCount();
	for (u32 i=0; i < m_numberItem; i++)
	{
		const GameListItem *iso = GetSelectedISO();

			if (!iso->IsCompressed() && _compress)
			{
				std::string FileName, FileExt;
				SplitPath(iso->GetFileName(), NULL, &FileName, &FileExt);
				m_currentFilename = FileName;
				FileName.append(".gcz");

				std::string OutputFileName;
				BuildCompleteFilename(OutputFileName,
						WxStrToStr(browseDialog.GetPath()),
						FileName);

				if (wxFileExists(StrToWxStr(OutputFileName)) &&
						wxMessageBox(
							wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
								StrToWxStr(OutputFileName)), 
							_("Confirm File Overwrite"),
							wxYES_NO) == wxNO)
					continue;

				all_good &= DiscIO::CompressFileToBlob(iso->GetFileName().c_str(),
						OutputFileName.c_str(),
						(iso->GetPlatform() == GameListItem::WII_DISC) ? 1 : 0,
						16384, &MultiCompressCB, &progressDialog);
			}
			else if (iso->IsCompressed() && !_compress)
			{
				std::string FileName, FileExt;
				SplitPath(iso->GetFileName(), NULL, &FileName, &FileExt);
				m_currentFilename = FileName;
				if (iso->GetPlatform() == GameListItem::WII_DISC)
					FileName.append(".iso");
				else
					FileName.append(".gcm");

				std::string OutputFileName;
				BuildCompleteFilename(OutputFileName,
						WxStrToStr(browseDialog.GetPath()),
						FileName);

				if (wxFileExists(StrToWxStr(OutputFileName)) &&
						wxMessageBox(
							wxString::Format(_("The file %s already exists.\nDo you wish to replace it?"),
								StrToWxStr(OutputFileName)), 
							_("Confirm File Overwrite"),
							wxYES_NO) == wxNO)
					continue;

				all_good &= DiscIO::DecompressBlobToFile(iso->GetFileName().c_str(),
						OutputFileName.c_str(), &MultiCompressCB, &progressDialog);
			}
			m_currentItem++;
	}
	}

	if (!all_good)
		wxMessageBox(_("Dolphin was unable to complete the requested action."));

	Update();
}
void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
{
	wxFont small_font(6, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);

	g_controller_interface.UpdateInput();

	// don't want game thread updating input when we are using it here
	std::unique_lock<std::recursive_mutex> lk(g_controller_interface.update_lock, std::try_to_lock);
	if (!lk.owns_lock())
		return;

	GamepadPage* const current_page = (GamepadPage*)m_pad_notebook->GetPage(m_pad_notebook->GetSelection());

	for (ControlGroupBox* g : current_page->control_groups)
	{
		// if this control group has a bitmap
		if (g->static_bitmap)
		{
			wxMemoryDC dc;
			wxBitmap bitmap(g->static_bitmap->GetBitmap());
			dc.SelectObject(bitmap);
			dc.Clear();

			dc.SetFont(small_font);
			dc.SetTextForeground(0xC0C0C0);

			// label for sticks and stuff
			if (64 == bitmap.GetHeight())
				dc.DrawText(StrToWxStr(g->control_group->name).Upper(), 4, 2);

			switch (g->control_group->type)
			{
			case GROUP_TYPE_TILT :
			case GROUP_TYPE_STICK :
			case GROUP_TYPE_CURSOR :
				{
					// this is starting to be a mess combining all these in one case

					float x = 0, y = 0, z = 0;
					float xx, yy;

					switch (g->control_group->type)
					{
					case GROUP_TYPE_STICK :
						((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y, 32.0, 32-1.5);
						break;
					case GROUP_TYPE_TILT :
						((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y, 32.0, 32-1.5);
						break;
					case GROUP_TYPE_CURSOR :
						((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
						x *= (32-1.5); x+= 32;
						y *= (32-1.5); y+= 32;
						break;
					}

					xx = g->control_group->controls[3]->control_ref->State();
					xx -= g->control_group->controls[2]->control_ref->State();
					yy = g->control_group->controls[1]->control_ref->State();
					yy -= g->control_group->controls[0]->control_ref->State();
					xx *= 32 - 1; xx += 32;
					yy *= 32 - 1; yy += 32;

					// draw the shit

					// ir cursor forward movement
					if (GROUP_TYPE_CURSOR == g->control_group->type)
					{
						if (z)
						{
							dc.SetPen(*wxRED_PEN);
							dc.SetBrush(*wxRED_BRUSH);
						}
						else
						{
							dc.SetPen(*wxGREY_PEN);
							dc.SetBrush(*wxGREY_BRUSH);
						}
						dc.DrawRectangle(0, 31 - z*31, 64, 2);
					}

					// octagon for visual aid for diagonal adjustment
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxWHITE_BRUSH);
					if (GROUP_TYPE_STICK == g->control_group->type)
					{
						// outline and fill colors
						wxBrush LightGrayBrush(_T("#dddddd"));
						wxPen LightGrayPen(_T("#bfbfbf"));
						dc.SetBrush(LightGrayBrush);
						dc.SetPen(LightGrayPen);

						// polygon offset
						float max
							, diagonal
							, box = 64
							, d_of = box / 256.0
							, x_of = box / 2.0;

						if (g->control_group->name == "Main Stick")
						{
							max = (87.0f / 127.0f) * 100;
							diagonal = (55.0f / 127.0f) * 100.0;
						}
						else if (g->control_group->name == "C-Stick")
						{
							max = (74.0f / 127.0f) * 100;
							diagonal = (46.0f / 127.0f) * 100;
						}
						else
						{
							max = (82.0f / 127.0f) * 100;
							diagonal = (58.0f / 127.0f) * 100;
						}

						// polygon corners
						wxPoint Points[8];
						Points[0].x = (int)(0.0 * d_of + x_of); Points[0].y = (int)(max * d_of + x_of);
						Points[1].x = (int)(diagonal * d_of + x_of); Points[1].y = (int)(diagonal * d_of + x_of);
						Points[2].x = (int)(max * d_of + x_of); Points[2].y = (int)(0.0 * d_of + x_of);
						Points[3].x = (int)(diagonal * d_of + x_of); Points[3].y = (int)(-diagonal * d_of + x_of);
						Points[4].x = (int)(0.0 * d_of + x_of); Points[4].y = (int)(-max * d_of + x_of);
						Points[5].x = (int)(-diagonal * d_of + x_of); Points[5].y = (int)(-diagonal * d_of + x_of);
						Points[6].x = (int)(-max * d_of + x_of); Points[6].y = (int)(0.0 * d_of + x_of);
						Points[7].x = (int)(-diagonal * d_of + x_of); Points[7].y = (int)(diagonal * d_of + x_of);

						// draw polygon
						dc.DrawPolygon(8, Points);
					}
					else
					{
						dc.DrawRectangle(16, 16, 32, 32);
					}

					if (GROUP_TYPE_CURSOR != g->control_group->type)
					{
						// deadzone circle
						dc.SetBrush(*wxLIGHT_GREY_BRUSH);
						dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
					}

					// raw dot
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					// i like the dot better than the cross i think
					dc.DrawRectangle(xx - 2, yy - 2, 4, 4);
					//dc.DrawRectangle(xx-1, 64-yy-4, 2, 8);
					//dc.DrawRectangle(xx-4, 64-yy-1, 8, 2);

					// adjusted dot
					if (x!=32 || y!=32)
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(x-2, 64-y-2, 4, 4);
						// i like the dot better than the cross i think
						//dc.DrawRectangle(x-1, 64-y-4, 2, 8);
						//dc.DrawRectangle(x-4, 64-y-1, 8, 2);
					}

				}
				break;
			case GROUP_TYPE_FORCE :
				{
					float raw_dot[3];
					float adj_dot[3];
					const float deadzone = 32 * g->control_group->settings[0]->value;

					// adjusted
					((ControllerEmu::Force*)g->control_group)->GetState(adj_dot, 32.0, 32-1.5);

					// raw
					for (unsigned int i=0; i<3; ++i)
					{
						raw_dot[i] = g->control_group->controls[i*2 + 1]->control_ref->State()
							- g->control_group->controls[i*2]->control_ref->State();
						raw_dot[i] *= 32 - 1; raw_dot[i] += 32;
					}

					// deadzone rect for forward/backward visual
					dc.SetBrush(*wxLIGHT_GREY_BRUSH);
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.DrawRectangle(0, 32 - deadzone, 64, deadzone * 2);

					// raw forward/background line
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					dc.DrawRectangle(0, raw_dot[2] - 1, 64, 2);

					// adjusted forward/background line
					if (adj_dot[2]!=32)
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(0, adj_dot[2] - 1, 64, 2);
					}

					// a rectangle, for looks i guess
					dc.SetBrush(*wxWHITE_BRUSH);
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.DrawRectangle(16, 16, 32, 32);

					// deadzone square
					dc.SetBrush(*wxLIGHT_GREY_BRUSH);
					dc.DrawRectangle(32 - deadzone, 32 - deadzone, deadzone * 2, deadzone * 2);

					// raw dot
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					dc.DrawRectangle(raw_dot[1] - 2, raw_dot[0] - 2, 4, 4);

					// adjusted dot
					if (adj_dot[1]!=32 || adj_dot[0]!=32)
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(adj_dot[1]-2, adj_dot[0]-2, 4, 4);
					}

				}
				break;
			case GROUP_TYPE_BUTTONS :
				{
					const unsigned int button_count = ((unsigned int)g->control_group->controls.size());

					// draw the shit
					dc.SetPen(*wxGREY_PEN);

					unsigned int * const bitmasks = new unsigned int[ button_count ];
					for (unsigned int n = 0; n<button_count; ++n)
						bitmasks[n] = (1 << n);

					unsigned int buttons = 0;
					((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);

					for (unsigned int n = 0; n<button_count; ++n)
					{
						if (buttons & bitmasks[n])
						{
							dc.SetBrush(*wxRED_BRUSH);
						}
						else
						{
							unsigned char amt = 255 - g->control_group->controls[n]->control_ref->State() * 128;
							dc.SetBrush(wxBrush(wxColor(amt, amt, amt)));
						}
						dc.DrawRectangle(n * 12, 0, 14, 12);

						// text
						const std::string name = g->control_group->controls[n]->name;
						// bit of hax so ZL, ZR show up as L, R
						dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1);
					}

					delete[] bitmasks;

				}
				break;
			case GROUP_TYPE_TRIGGERS :
				{
					const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size()));

					// draw the shit
					dc.SetPen(*wxGREY_PEN);
					ControlState deadzone =  g->control_group->settings[0]->value;

					unsigned int* const trigs = new unsigned int[trigger_count];
					((ControllerEmu::Triggers*)g->control_group)->GetState(trigs, 64);

					for (unsigned int n = 0; n < trigger_count; ++n)
					{
						ControlState trig_r = g->control_group->controls[n]->control_ref->State();

						// outline
						dc.SetPen(*wxGREY_PEN);
						dc.SetBrush(*wxWHITE_BRUSH);
						dc.DrawRectangle(0, n*12, 64, 14);

						// raw
						dc.SetBrush(*wxGREY_BRUSH);
						dc.DrawRectangle(0, n*12, trig_r*64, 14);

						// deadzone affected
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(0, n*12, trigs[n], 14);

						// text
						dc.DrawText(StrToWxStr(g->control_group->controls[n]->name), 3, n*12 + 1);
					}

					delete[] trigs;

					// deadzone box
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxTRANSPARENT_BRUSH);
					dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);

				}
				break;
			case GROUP_TYPE_MIXED_TRIGGERS :
				{
					const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));

					// draw the shit
					dc.SetPen(*wxGREY_PEN);
					ControlState thresh = g->control_group->settings[0]->value;

					for (unsigned int n = 0; n < trigger_count; ++n)
					{
						dc.SetBrush(*wxRED_BRUSH);
						ControlState trig_d = g->control_group->controls[n]->control_ref->State();

						ControlState trig_a = trig_d > thresh ? 1
							: g->control_group->controls[n+trigger_count]->control_ref->State();

						dc.DrawRectangle(0, n*12, 64+20, 14);
						if (trig_d <= thresh)
							dc.SetBrush(*wxWHITE_BRUSH);
						dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
						dc.DrawRectangle(64, n*12, 32, 14);

						// text
						dc.DrawText(StrToWxStr(g->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
						dc.DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
					}

					// threshold box
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxTRANSPARENT_BRUSH);
					dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);

				}
				break;
			case GROUP_TYPE_SLIDER:
				{
					const ControlState deadzone = g->control_group->settings[0]->value;

					ControlState state = g->control_group->controls[1]->control_ref->State() - g->control_group->controls[0]->control_ref->State();
					dc.SetPen(*wxGREY_PEN);
					dc.SetBrush(*wxGREY_BRUSH);
					dc.DrawRectangle(31 + state * 30, 0, 2, 14);

					((ControllerEmu::Slider*)g->control_group)->GetState(&state, 1);
					if (state)
					{
						dc.SetPen(*wxRED_PEN);
						dc.SetBrush(*wxRED_BRUSH);
						dc.DrawRectangle(31 + state * 30, 0, 2, 14);
					}

					// deadzone box
					dc.SetPen(*wxLIGHT_GREY_PEN);
					dc.SetBrush(*wxTRANSPARENT_BRUSH);
					dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
				}
				break;
			default :
				break;
			}

			// box outline
			// Windows XP color
			dc.SetPen(wxPen(_T("#7f9db9")));
			dc.SetBrush(*wxTRANSPARENT_BRUSH);
			dc.DrawRectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight());

			dc.SelectObject(wxNullBitmap);
			g->static_bitmap->SetBitmap(bitmap);
		}
	}
}
Example #15
0
void GameCubeConfigPane::ChooseSlotPath(bool is_slot_a, TEXIDevices device_type)
{
	bool memcard = (device_type == EXIDEVICE_MEMORYCARD);
	std::string path;
	std::string cardname;
	std::string ext;
	std::string pathA = SConfig::GetInstance().m_strMemoryCardA;
	std::string pathB = SConfig::GetInstance().m_strMemoryCardB;
	if (!memcard)
	{
		pathA = SConfig::GetInstance().m_strGbaCartA;
		pathB = SConfig::GetInstance().m_strGbaCartB;
	}
	SplitPath(is_slot_a ? pathA : pathB, &path, &cardname, &ext);
	std::string filename = WxStrToStr(wxFileSelector(
		_("Choose a file to open"), StrToWxStr(path), StrToWxStr(cardname), StrToWxStr(ext),
		memcard ? _("GameCube Memory Cards (*.raw,*.gcp)") + "|*.raw;*.gcp" :
		_("Game Boy Advance Carts (*.gba)") + "|*.gba"));

	if (!filename.empty())
	{
		if (File::Exists(filename))
		{
			if (memcard)
			{
				GCMemcard memorycard(filename);
				if (!memorycard.IsValid())
				{
					WxUtils::ShowErrorDialog(wxString::Format(_("Cannot use that file as a memory card.\n%s\n"
						"is not a valid GameCube memory card file"),
						filename.c_str()));
					return;
				}
			}
		}

		wxFileName newFilename(filename);
		newFilename.MakeAbsolute();
		filename = newFilename.GetFullPath();

#ifdef _WIN32
		// If the Memory Card file is within the Exe dir, we can assume that the user wants it to be
		// stored relative
		// to the executable, so it stays set correctly when the probably portable Exe dir is moved.
		// TODO: Replace this with a cleaner, non-wx solution once std::filesystem is standard
		std::string exeDir = File::GetExeDirectory() + '\\';
		if (wxString(filename).Lower().StartsWith(wxString(exeDir).Lower()))
			filename.erase(0, exeDir.size());

		std::replace(filename.begin(), filename.end(), '\\', '/');
#endif

		// also check that the path isn't used for the other memcard...
		wxFileName otherFilename(is_slot_a ? pathB : pathA);
		otherFilename.MakeAbsolute();
		if (newFilename.GetFullPath().compare(otherFilename.GetFullPath()) != 0)
		{
			if (memcard)
			{
				if (is_slot_a)
					SConfig::GetInstance().m_strMemoryCardA = filename;
				else
					SConfig::GetInstance().m_strMemoryCardB = filename;
			}
			else
			{
				if (is_slot_a)
					SConfig::GetInstance().m_strGbaCartA = filename;
				else
					SConfig::GetInstance().m_strGbaCartB = filename;
			}

			if (Core::IsRunning())
			{
				// Change memcard to the new file
				ExpansionInterface::ChangeDevice(is_slot_a ? 0 : 1,  // SlotA: channel 0, SlotB channel 1
					device_type,
					0);  // SP1 is device 2, slots are device 0
			}
		}
		else
		{
			WxUtils::ShowErrorDialog(_("Are you trying to use the same file in both slots?"));
		}
	}
}
Example #16
0
void CMemcardManager::CreateGUIControls()
{
	// Create the controls for both memcards

	const char* ARROW[2] = { "<-", "->" };

	m_ConvertToGci = new wxButton(this, ID_CONVERTTOGCI, _("Convert to GCI"));

	wxStaticBoxSizer *sMemcard[2];

	for (int slot = SLOT_A; slot <= SLOT_B; slot++)
	{
		m_CopyFrom[slot]    = new wxButton(this, ID_COPYFROM_A + slot,
			wxString::Format(_("%1$sCopy%1$s"), ARROW[slot ? 0 : 1]));
		m_SaveImport[slot]  = new wxButton(this, ID_SAVEIMPORT_A + slot,
			wxString::Format(_("%sImport GCI%s"), ARROWS));
		m_SaveExport[slot]  = new wxButton(this, ID_SAVEEXPORT_A + slot,
			wxString::Format(_("%sExport GCI%s"), ARROWS));
		m_Delete[slot]      = new wxButton(this, ID_DELETE_A + slot,
			wxString::Format(_("%sDelete%s"), ARROWS));


		m_PrevPage[slot] = new wxButton(this, ID_PREVPAGE_A + slot, _("Prev Page"));
		m_NextPage[slot] = new wxButton(this, ID_NEXTPAGE_A + slot, _("Next Page"));

		t_Status[slot] = new wxStaticText(this, 0, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString);

		wxBoxSizer * const sPages = new wxBoxSizer(wxHORIZONTAL);
		sPages->Add(m_PrevPage[slot], 0, wxEXPAND | wxALL, 1);
		sPages->Add(t_Status[slot], 0, wxEXPAND | wxALL, 5);
		sPages->Add(0, 0, 1, wxEXPAND|wxALL, 0);
		sPages->Add(m_NextPage[slot], 0, wxEXPAND | wxALL, 1);

		m_MemcardPath[slot] = new wxFilePickerCtrl(this, ID_MEMCARDPATH_A + slot,
			 StrToWxStr(File::GetUserPath(D_GCUSER_IDX)), _("Choose a memory card:"),
		_("GameCube Memory Cards (*.raw,*.gcp)") + wxString("|*.raw;*.gcp"), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL | wxFLP_OPEN);

		m_MemcardList[slot] = new CMemcardListCtrl(this, ID_MEMCARDLIST_A + slot, wxDefaultPosition, wxSize(350, 400),
		wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL, mcmSettings);

		m_MemcardList[slot]->AssignImageList(new wxImageList(96, 32), wxIMAGE_LIST_SMALL);

		sMemcard[slot] = new wxStaticBoxSizer(wxVERTICAL, this, _("Memory Card") + wxString::Format(" %c", 'A' + slot));
		sMemcard[slot]->Add(m_MemcardPath[slot], 0, wxEXPAND | wxALL, 5);
		sMemcard[slot]->Add(m_MemcardList[slot], 1, wxEXPAND | wxALL, 5);
		sMemcard[slot]->Add(sPages, 0, wxEXPAND | wxALL, 1);
	}

	wxBoxSizer * const sButtons = new wxBoxSizer(wxVERTICAL);
	sButtons->AddStretchSpacer(2);
	sButtons->Add(m_CopyFrom[SLOT_B],   0, wxEXPAND, 5);
	sButtons->Add(m_CopyFrom[SLOT_A],   0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_SaveImport[SLOT_A], 0, wxEXPAND, 5);
	sButtons->Add(m_SaveExport[SLOT_A], 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_ConvertToGci,       0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_SaveImport[SLOT_B], 0, wxEXPAND, 5);
	sButtons->Add(m_SaveExport[SLOT_B], 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer(1);
	sButtons->Add(m_Delete[SLOT_A],     0, wxEXPAND, 5);
	sButtons->Add(m_Delete[SLOT_B],     0, wxEXPAND, 5);
	sButtons->AddStretchSpacer();
	sButtons->Add(new wxButton(this, wxID_OK, _("Close")), 0, wxEXPAND, 5);
	sButtons->AddStretchSpacer();

	wxBoxSizer * const sMain = new wxBoxSizer(wxHORIZONTAL);
	sMain->Add(sMemcard[SLOT_A], 1, wxEXPAND | wxALL, 5);
	sMain->Add(sButtons, 0, wxEXPAND, 0);
	sMain->Add(sMemcard[SLOT_B], 1, wxEXPAND | wxALL, 5);

	SetSizerAndFit(sMain);
	Center();

	for (int i = SLOT_A; i <= SLOT_B; i++)
	{
		m_PrevPage[i]->Disable();
		m_NextPage[i]->Disable();
		m_CopyFrom[i]->Disable();
		m_SaveImport[i]->Disable();
		m_SaveExport[i]->Disable();
		m_Delete[i]->Disable();
		if (DefaultMemcard[i].length())
		{
			m_MemcardPath[i]->SetPath(StrToWxStr(DefaultMemcard[i]));
			ChangePath(i);
		}
	}
}
Example #17
0
void LogConfigWindow::CreateGUIControls()
{
	// Verbosity
	wxArrayString wxLevels, wxLevelsUse;
	wxLevels.Add(_("Notice"));
	wxLevels.Add(_("Error"));
	wxLevels.Add(_("Warning"));
	wxLevels.Add(_("Info"));
	wxLevels.Add(_("Debug"));
	for (int i = 0; i < MAX_LOGLEVEL; ++i)
		wxLevelsUse.Add(wxLevels[i]);
	m_verbosity = new wxRadioBox(this, wxID_ANY, _("Verbosity"),
			wxDefaultPosition, wxDefaultSize, wxLevelsUse, 0, wxRA_SPECIFY_ROWS);
	m_verbosity->Bind(wxEVT_RADIOBOX, &LogConfigWindow::OnVerbosityChange, this);

	// Options
	m_writeFileCB = new wxCheckBox(this, wxID_ANY, _("Write to File"));
	m_writeFileCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteFileChecked, this);
	m_writeConsoleCB = new wxCheckBox(this, wxID_ANY, _("Write to Console"));
	m_writeConsoleCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteConsoleChecked, this);
	m_writeWindowCB = new wxCheckBox(this, wxID_ANY, _("Write to Window"));
	m_writeWindowCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteWindowChecked, this);
	m_writeDebuggerCB = nullptr;
#ifdef _MSC_VER
	if (IsDebuggerPresent())
	{
		m_writeDebuggerCB = new wxCheckBox(this, wxID_ANY, _("Write to Debugger"));
		m_writeDebuggerCB->Bind(wxEVT_CHECKBOX, &LogConfigWindow::OnWriteDebuggerChecked, this);
	}
#endif

	wxButton *btn_toggle_all = new wxButton(this, wxID_ANY, _("Toggle All Log Types"),
			wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
	btn_toggle_all->Bind(wxEVT_BUTTON, &LogConfigWindow::OnToggleAll, this);
	m_checks = new wxCheckListBox(this, wxID_ANY);
	m_checks->Bind(wxEVT_CHECKLISTBOX, &LogConfigWindow::OnLogCheck, this);
	for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
		m_checks->Append(StrToWxStr(m_LogManager->GetFullName((LogTypes::LOG_TYPE)i)));

	// Sizers
	wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
	sbOutputs->Add(m_writeFileCB, 0, wxDOWN, 1);
	sbOutputs->Add(m_writeConsoleCB, 0, wxDOWN, 1);
#ifdef _MSC_VER
	if (m_writeDebuggerCB)
	{
		sbOutputs->Add(m_writeWindowCB, 0, wxDOWN, 1);
		sbOutputs->Add(m_writeDebuggerCB, 0);
	}
	else
#endif
	{
		sbOutputs->Add(m_writeWindowCB, 0);
	}

	wxStaticBoxSizer* sbLogTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Log Types"));
	sbLogTypes->Add(m_checks, 1, wxEXPAND);

	wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
	sMain->Add(m_verbosity, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
	sMain->Add(sbOutputs, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
	sMain->Add(btn_toggle_all, 0, wxEXPAND | wxLEFT | wxRIGHT, 5);
	sMain->Add(sbLogTypes, 1, wxEXPAND | wxLEFT | wxRIGHT, 5);

	SetSizer(sMain);
	Layout();
}
Example #18
0
void CMemcardManager::CopyDeleteClick(wxCommandEvent& event)
{
	int index_A = m_MemcardList[SLOT_A]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	int index_B = m_MemcardList[SLOT_B]->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
	int slot = SLOT_B;
	int slot2 = SLOT_A;
	std::string fileName2("");

	if (index_A != wxNOT_FOUND && page[SLOT_A]) index_A += itemsPerPage * page[SLOT_A];
	if (index_B != wxNOT_FOUND && page[SLOT_B]) index_B += itemsPerPage * page[SLOT_B];

	int index = index_B;
	switch (event.GetId())
	{
	case ID_COPYFROM_B:
		slot = SLOT_A;
		slot2 = SLOT_B;
	case ID_COPYFROM_A:
		index = slot2 ? index_B : index_A;
		index = memoryCard[slot2]->GetFileIndex(index);
		if ((index != wxNOT_FOUND))
		{
			CopyDeleteSwitch(memoryCard[slot]->CopyFrom(*memoryCard[slot2], index), slot);
		}
		break;
	case ID_FIXCHECKSUM_A:
		slot = SLOT_A;
	case ID_FIXCHECKSUM_B:
		if (memoryCard[slot]->FixChecksums() && memoryCard[slot]->Save())
		{
			wxMessageBox(_("The checksum was successfully fixed."));
		}
		else
		{
			WxUtils::ShowErrorDialog(_("File write failed"));
		}
		break;
	case ID_CONVERTTOGCI:
		fileName2 = "convert";
	case ID_SAVEIMPORT_A:
		slot = SLOT_A;
	case ID_SAVEIMPORT_B:
	{
		wxString fileName = wxFileSelector(
			_("Select a save file to import"),
			(strcmp(DefaultIOPath.c_str(), "/Users/GC") == 0)
				? StrToWxStr("")
				: StrToWxStr(DefaultIOPath),
			wxEmptyString, wxEmptyString,
			_("GameCube Savegame files(*.gci;*.gcs;*.sav)") + wxString("|*.gci;*.gcs;*.sav|") +
			_("Native GCI files(*.gci)") + wxString("|*.gci|") +
			_("MadCatz Gameshark files(*.gcs)") + wxString("|*.gcs|") +
			_("Datel MaxDrive/Pro files(*.sav)") + wxString("|*.sav"),
			wxFD_OPEN | wxFD_FILE_MUST_EXIST, this);
		if (!fileName.empty() && !fileName2.empty())
		{
			wxString temp2 = wxFileSelector(_("Save GCI as..."),
				wxEmptyString, wxEmptyString, ".gci",
				_("GCI File(*.gci)") + wxString("|*.gci"),
				wxFD_OVERWRITE_PROMPT | wxFD_SAVE, this);

			if (temp2.empty())
				break;

			fileName2 = WxStrToStr(temp2);
		}
		if (fileName.length() > 0)
		{
			CopyDeleteSwitch(memoryCard[slot]->ImportGci(WxStrToStr(fileName), fileName2), slot);
		}
	}
	break;
	case ID_SAVEEXPORT_A:
		slot = SLOT_A;
		index = index_A;
	case ID_SAVEEXPORT_B:
		index = memoryCard[slot]->GetFileIndex(index);
		if (index != wxNOT_FOUND)
		{
			std::string gciFilename;
			if (!memoryCard[slot]->GCI_FileName(index, gciFilename))
			{
				wxMessageBox(_("Invalid index"), _("Error"));
				return;
			}
			wxString fileName = wxFileSelector(
				_("Export save as..."),
				StrToWxStr(DefaultIOPath),
				StrToWxStr(gciFilename), ".gci",
				_("Native GCI files(*.gci)") + wxString("|*.gci|") +
				_("MadCatz Gameshark files(*.gcs)") + wxString("|*.gcs|") +
				_("Datel MaxDrive/Pro files(*.sav)") + wxString("|*.sav"),
				wxFD_OVERWRITE_PROMPT | wxFD_SAVE, this);

			if (fileName.length() > 0)
			{
				if (!CopyDeleteSwitch(memoryCard[slot]->ExportGci(index, WxStrToStr(fileName), ""), -1))
				{
					File::Delete(WxStrToStr(fileName));
				}
			}
		}
		break;
	case ID_EXPORTALL_A:
		slot = SLOT_A;
	case ID_EXPORTALL_B:
	{
		std::string path1, path2, mpath;
		mpath = WxStrToStr(m_MemcardPath[slot]->GetPath());
		SplitPath(mpath, &path1, &path2, nullptr);
		path1 += path2;
		File::CreateDir(path1);

		int answer = wxMessageBox(wxString::Format(_("Warning: This will overwrite any existing saves that are in the folder:\n"
		                                             "%s\nand have the same name as a file on your memcard\nContinue?"), path1.c_str()), _("Warning"), wxYES_NO);
		if (answer == wxYES)
		{
			for (int i = 0; i < DIRLEN; i++)
			{
				CopyDeleteSwitch(memoryCard[slot]->ExportGci(i, "", path1), -1);
			}
		}

		break;
	}
	case ID_DELETE_A:
		slot = SLOT_A;
		index = index_A;
	case ID_DELETE_B:
		index = memoryCard[slot]->GetFileIndex(index);
		if (index != wxNOT_FOUND)
		{
			CopyDeleteSwitch(memoryCard[slot]->RemoveFile(index), slot);
		}
		break;
	}
}
Example #19
0
static wxImage LoadScaledImage(const std::string& file_path, const wxWindow* context,
                               const wxSize& output_size, const wxRect& usable_rect, LSIFlags flags,
                               const wxColour& fill_color)
{
  std::string fpath, fname, fext;
  SplitPath(file_path, &fpath, &fname, &fext);

  const double window_scale_factor = context->GetContentScaleFactor();
  // Compute the total scale factor from the ratio of DIPs to window pixels (FromDIP) and
  // window pixels to framebuffer pixels (GetContentScaleFactor).
  // NOTE: Usually only one of these is meaningful:
  //   - On Windows/GTK2: content_scale = 1.0, FromDIP = 96DPI -> Screen DPI
  //   - On Mac OS X: content_scale = screen_dpi / 96, FromDIP = 96DPI -> 96DPI (no-op)
  // [The 1024 is arbitrarily large to minimise rounding error, it has no significance]
  const double scale_factor = (context->FromDIP(1024) / 1024.0) * window_scale_factor;

  // We search for files on quarter ratios of DIPs to framebuffer pixels.
  // By default, the algorithm prefers to find an exact or bigger size then downscale if
  // needed but will resort to upscaling if a bigger image cannot be found.
  // E.g. A basic retina screen on Mac OS X has a scale_factor of 2.0, so we would look for
  // @2x, @2.25x, @2.5x, @2.75x, @3x, @1.75x, @1.5x, @1.25x, @1x, then give up.
  // (At 125% on Windows the search is @1.25, @1.5, @1.75, @2, @2.25, @1)
  // If flags does not include LSI_SCALE_DOWN (i.e. we would be forced to crop big
  // images instead of scaling them) then we will only accept smaller sizes, i.e.
  // @2x, @1.75, @1.5, @1.25, @1, then give up.
  // NOTE: We do a lot of exact comparisons against floating point here but it's fine
  //   because the numbers involved are all powers of 2 so can be represented exactly.
  wxImage image;
  double selected_image_scale = 1;
  {
    auto image_check = [&](double scale) -> bool {
      std::string path = fpath + fname + StringFromFormat("@%gx", scale) + fext;
      if (!File::Exists(path))
      {
        // Special Case: @1x may not have a suffix at all.
        if (scale != 1.0 || !File::Exists(file_path))
          return false;
        path = file_path;
      }
      if (!image.LoadFile(StrToWxStr(path), wxBITMAP_TYPE_ANY))
        return false;
      selected_image_scale = scale;
      return true;
    };
    const bool prefer_smaller = !(flags & LSI_SCALE_DOWN);
    const double scale_factor_quarter =
        prefer_smaller ? std::floor(scale_factor * 4) / 4 : std::ceil(scale_factor * 4) / 4;
    // Search for bigger sizes first (preferred)
    if (!prefer_smaller)
    {
      // We search within a 'circle' of the exact match limited by scale=1.0.
      // i.e. scale_factor = 1.5, radius = 0.5; scale = 2.5, radius = 1.5.
      // The minimum radius is 1.0.
      double limit = std::max(scale_factor_quarter * 2 - 1, scale_factor_quarter + 1);
      for (double quarter = scale_factor_quarter; quarter <= limit; quarter += 0.25)
      {
        if (image_check(quarter))
          break;
      }
    }
    // If we didn't hit a bigger size then we'll fallback to looking for smaller ones
    if (!image.IsOk())
    {
      double quarter = scale_factor_quarter;
      if (!prefer_smaller)  // So we don't recheck the exact match
        quarter -= 0.25;
      for (; quarter >= 1.0; quarter -= 0.25)
      {
        if (image_check(quarter))
          break;
      }
    }
  }

  // The file apparently does not exist so we give up. Create a white square placeholder instead.
  if (!image.IsOk())
  {
    wxLogError("Could not find resource: %s", StrToWxStr(file_path));
    image.Create(1, 1, false);
    image.Clear(0xFF);
  }

  return ScaleImage(image, selected_image_scale, window_scale_factor, output_size, usable_rect,
                    flags, fill_color);
}
Example #20
0
bool CMemcardManager::ReloadMemcard(const std::string& fileName, int card)
{
	if (memoryCard[card]) delete memoryCard[card];

	// TODO: add error checking and animate icons
	memoryCard[card] = new GCMemcard(fileName);

	if (!memoryCard[card]->IsValid())
		return false;

	int j;

	wxString wxTitle,
			 wxComment,
			 wxBlock,
			 wxFirstBlock,
			 wxLabel;


	m_MemcardList[card]->Hide();
	m_MemcardList[card]->ClearAll();

	m_MemcardList[card]->InsertColumn(COLUMN_BANNER, _("Banner"));
	m_MemcardList[card]->InsertColumn(COLUMN_TITLE, _("Title"));
	m_MemcardList[card]->InsertColumn(COLUMN_COMMENT, _("Comment"));
	m_MemcardList[card]->InsertColumn(COLUMN_ICON, _("Icon"));
	m_MemcardList[card]->InsertColumn(COLUMN_BLOCKS, _("Blocks"));
	m_MemcardList[card]->InsertColumn(COLUMN_FIRSTBLOCK, _("First Block"));

	wxImageList *list = m_MemcardList[card]->GetImageList(wxIMAGE_LIST_SMALL);
	list->RemoveAll();

	u8 nFiles = memoryCard[card]->GetNumFiles();
	std::vector<int> images(nFiles * 2);

	for (u8 i = 0; i < nFiles; i++)
	{
		static u32 pxdata[96*32];
		static u8  animDelay[8];
		static u32 animData[32*32*8];

		u8 fileIndex = memoryCard[card]->GetFileIndex(i);
		int numFrames = memoryCard[card]->ReadAnimRGBA8(fileIndex, animData, animDelay);

		if (!memoryCard[card]->ReadBannerRGBA8(fileIndex, pxdata))
		{
			memset(pxdata, 0, 96*32*4);

			if (numFrames > 0) // Just use the first one
			{
				u32 *icdata = animData;

				for (int y = 0; y < 32; y++)
				{
					for (int x = 0; x < 32; x++)
					{
						pxdata[y*96 + x + 32] = icdata[y*32 + x];//  | 0xFF000000
					}
				}
			}
		}

		wxBitmap map = wxBitmapFromMemoryRGBA((u8*)pxdata, 96, 32);
		images[i*2] = list->Add(map);

		if (numFrames > 0)
		{
			memset(pxdata, 0, 96*32*4);
			int frames = 3;

			if (numFrames < frames)
				frames = numFrames;

			for (int f = 0; f < frames; f++)
			{
				for (int y = 0; y < 32; y++)
				{
					for (int x = 0; x < 32; x++)
					{
						pxdata[y*96 + x + 32*f] = animData[f*32*32 + y*32 + x];
					}
				}
			}
			wxBitmap icon = wxBitmapFromMemoryRGBA((u8*)pxdata, 96, 32);
			images[i*2 + 1] = list->Add(icon);
		}
	}

	int pagesMax = (mcmSettings.usePages) ?
					(page[card] + 1) * itemsPerPage : 128;

	for (j = page[card] * itemsPerPage; (j < nFiles) && (j < pagesMax); j++)
	{
		u16 blocks;
		u16 firstblock;
		u8 fileIndex = memoryCard[card]->GetFileIndex(j);


		int index = m_MemcardList[card]->InsertItem(j, wxEmptyString);

		m_MemcardList[card]->SetItem(index, COLUMN_BANNER, wxEmptyString);

		std::string title = memoryCard[card]->GetSaveComment1(fileIndex);
		std::string comment = memoryCard[card]->GetSaveComment2(fileIndex);

		auto const string_decoder = memoryCard[card]->IsAsciiEncoding() ?
			CP1252ToUTF8 : SHIFTJISToUTF8;

		wxTitle = StrToWxStr(string_decoder(title));
		wxComment = StrToWxStr(string_decoder(comment));

		m_MemcardList[card]->SetItem(index, COLUMN_TITLE, wxTitle);
		m_MemcardList[card]->SetItem(index, COLUMN_COMMENT, wxComment);

		blocks = memoryCard[card]->DEntry_BlockCount(fileIndex);

		if (blocks == 0xFFFF)
			blocks = 0;

		wxBlock.Printf("%10d", blocks);
		m_MemcardList[card]->SetItem(index, COLUMN_BLOCKS, wxBlock);
		firstblock = memoryCard[card]->DEntry_FirstBlock(fileIndex);
		//if (firstblock == 0xFFFF) firstblock = 3; // to make firstblock -1
		wxFirstBlock.Printf("%15d", firstblock);
		m_MemcardList[card]->SetItem(index, COLUMN_FIRSTBLOCK, wxFirstBlock);
		m_MemcardList[card]->SetItem(index, COLUMN_ICON, wxEmptyString);

		if (images[j] >= 0)
		{
			m_MemcardList[card]->SetItemImage(index, images[j*2]);
			m_MemcardList[card]->SetItemColumnImage(index, COLUMN_ICON, images[j*2 + 1]);
		}
	}

	if (mcmSettings.usePages)
	{
		if (nFiles <= itemsPerPage)
		{
			m_PrevPage[card]->Disable();
			m_MemcardList[card]->prevPage = false;
		}
		if (j == nFiles)
		{
			m_NextPage[card]->Disable();
			m_MemcardList[card]->nextPage = false;
		}
		else
		{
			m_NextPage[card]->Enable();
			m_MemcardList[card]->nextPage = true;
		}
	}

	// Automatic column width and then show the list
	for (int i = COLUMN_BANNER; i <= COLUMN_FIRSTBLOCK; i++)
	{
		if (mcmSettings.column[i])
			m_MemcardList[card]->SetColumnWidth(i, wxLIST_AUTOSIZE);
		else
			m_MemcardList[card]->SetColumnWidth(i, 0);
	}

	m_MemcardList[card]->Show();
	wxLabel.Printf(_("%u Free Blocks; %u Free Dir Entries"),
		memoryCard[card]->GetFreeBlocks(), DIRLEN - nFiles);
	t_Status[card]->SetLabel(wxLabel);

	// Done so text doesn't overlap the UI.
	this->Fit();

	return true;
}
Example #21
0
void CMemoryView::OnPaint(wxPaintEvent& event)
{
	wxPaintDC dc(this);
	wxRect rc = GetClientRect();
	wxFont hFont("Courier");
	hFont.SetFamily(wxFONTFAMILY_TELETYPE);

	wxCoord w,h;
	dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &hFont);
	if (h > rowHeight)
		rowHeight = h;
	dc.GetTextExtent("0WJyq", &w, &h, nullptr, nullptr, &DebuggerFont);
	if (h > rowHeight)
		rowHeight = h;

	if (viewAsType==VIEWAS_HEX)
		dc.SetFont(hFont);
	else
		dc.SetFont(DebuggerFont);

	dc.GetTextExtent("W", &w, &h);
	int fontSize = w;
	int textPlacement = 17 + 9 * fontSize;

	// TODO: Add any drawing code here...
	int width   = rc.width;
	int numRows = (rc.height / rowHeight) / 2 + 2;
	dc.SetBackgroundMode(wxTRANSPARENT);
	const wxColour bgColor = *wxWHITE;
	wxPen nullPen(bgColor);
	wxPen currentPen(*wxBLACK_PEN);
	wxPen selPen(*wxGREY_PEN);
	nullPen.SetStyle(wxTRANSPARENT);

	wxBrush currentBrush(*wxLIGHT_GREY_BRUSH);
	wxBrush pcBrush(*wxGREEN_BRUSH);
	wxBrush mcBrush(*wxBLUE_BRUSH);
	wxBrush bgBrush(bgColor);
	wxBrush nullBrush(bgColor);
	nullBrush.SetStyle(wxTRANSPARENT);

	dc.SetPen(nullPen);
	dc.SetBrush(bgBrush);
	dc.DrawRectangle(0, 0, 16, rc.height);
	dc.DrawRectangle(0, 0, rc.width, 5+8);

	// TODO - clean up this freaking mess!!!!!
	for (int row = -numRows; row <= numRows; row++)
	{
		unsigned int address = curAddress + row * align;

		int rowY1 = rc.height / 2 + rowHeight * row - rowHeight / 2;
		int rowY2 = rc.height / 2 + rowHeight * row + rowHeight / 2;

		wxString temp = wxString::Format("%08x", address);
		u32 col = debugger->GetColor(address);
		wxBrush rowBrush(wxColour(col >> 16, col >> 8, col));
		dc.SetBrush(nullBrush);
		dc.SetPen(nullPen);
		dc.DrawRectangle(0, rowY1, 16, rowY2);

		if (selecting && (address == selection))
			dc.SetPen(selPen);
		else
			dc.SetPen(row == 0 ? currentPen : nullPen);

		if (address == debugger->GetPC())
			dc.SetBrush(pcBrush);
		else
			dc.SetBrush(rowBrush);

		dc.DrawRectangle(16, rowY1, width, rowY2 - 1);
		dc.SetBrush(currentBrush);
		dc.SetTextForeground("#600000"); // Dark red
		dc.DrawText(temp, 17, rowY1);

		if (viewAsType != VIEWAS_HEX)
		{
			char mem[256];
			debugger->GetRawMemoryString(memory, address, mem, 256);
			dc.SetTextForeground(wxTheColourDatabase->Find("NAVY"));
			dc.DrawText(StrToWxStr(mem), 17+fontSize*(8), rowY1);
			dc.SetTextForeground(*wxBLACK);
		}

		if (!PowerPC::HostIsRAMAddress(address))
			continue;

		if (debugger->IsAlive())
		{
			std::string dis;
			u32 mem_data = debugger->ReadExtraMemory(memory, address);

			if (viewAsType == VIEWAS_FP)
			{
				float flt = *(float *)(&mem_data);
				dis = StringFromFormat("f: %f", flt);
			}
			else if (viewAsType == VIEWAS_ASCII)
			{
				u32 a[4] = {
					(mem_data & 0xff000000) >> 24,
					(mem_data & 0xff0000) >> 16,
					(mem_data & 0xff00) >> 8,
					(mem_data & 0xff)
				};

				for (auto& word : a)
				{
					if (word == '\0')
						word = ' ';
				}

				dis = StringFromFormat("%c%c%c%c", a[0], a[1], a[2], a[3]);
			}
			else if (viewAsType == VIEWAS_HEX)
Example #22
0
void CARCodeAddEdit::ChangeEntry(wxSpinEvent& event)
{
    ActionReplay::ARCode currentCode = arCodes->at((int)arCodes->size() - event.GetPosition());
    EditCheatName->SetValue(StrToWxStr(currentCode.name));
    UpdateTextCtrl(currentCode);
}
Example #23
0
bool DolphinApp::OnInit()
{
	if (!wxApp::OnInit())
		return false;

	Bind(wxEVT_QUERY_END_SESSION, &DolphinApp::OnEndSession, this);
	Bind(wxEVT_END_SESSION, &DolphinApp::OnEndSession, this);

	// Register message box and translation handlers
	RegisterMsgAlertHandler(&wxMsgAlert);
	RegisterStringTranslator(&wxStringTranslator);

#if wxUSE_ON_FATAL_EXCEPTION
	wxHandleFatalExceptions(true);
#endif

	UICommon::SetUserDirectory(m_user_path.ToStdString());
	UICommon::CreateDirectories();
	InitLanguageSupport(); // The language setting is loaded from the user directory
	UICommon::Init();

	if (m_select_video_backend && !m_video_backend_name.empty())
		SConfig::GetInstance().m_strVideoBackend = WxStrToStr(m_video_backend_name);

	if (m_select_audio_emulation)
		SConfig::GetInstance().bDSPHLE = (m_audio_emulation_name.Upper() == "HLE");

	VideoBackendBase::ActivateBackend(SConfig::GetInstance().m_strVideoBackend);

	// Enable the PNG image handler for screenshots
	wxImage::AddHandler(new wxPNGHandler);

	int x = SConfig::GetInstance().iPosX;
	int y = SConfig::GetInstance().iPosY;
	int w = SConfig::GetInstance().iWidth;
	int h = SConfig::GetInstance().iHeight;

	// The following is not needed with X11, where window managers
	// do not allow windows to be created off the desktop.
#ifdef _WIN32
	// Out of desktop check
	int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN);
	int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN);
	int width =  GetSystemMetrics(SM_CXVIRTUALSCREEN);
	int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
	if ((leftPos + width) < (x + w) || leftPos > x || (topPos + height) < (y + h) || topPos > y)
		x = y = wxDefaultCoord;
#elif defined __APPLE__
	if (y < 1)
		y = wxDefaultCoord;
#endif

	main_frame = new CFrame(nullptr, wxID_ANY,
	                        StrToWxStr(scm_rev_str),
	                        wxPoint(x, y), wxSize(w, h),
	                        m_use_debugger, m_batch_mode, m_use_logger);

	SetTopWindow(main_frame);
	main_frame->SetMinSize(wxSize(400, 300));

	AfterInit();

	return true;
}
Example #24
0
void CISOProperties::LoadGameConfig()
{
  SetCheckboxValueFromGameini("Core", "CPUThread", CPUThread);
  SetCheckboxValueFromGameini("Core", "MMU", MMU);
  SetCheckboxValueFromGameini("Core", "DCBZ", DCBZOFF);
  SetCheckboxValueFromGameini("Core", "FPRF", FPRF);
  SetCheckboxValueFromGameini("Core", "SyncGPU", SyncGPU);
  SetCheckboxValueFromGameini("Core", "FastDiscSpeed", FastDiscSpeed);
  SetCheckboxValueFromGameini("Core", "DSPHLE", DSPHLE);
  SetCheckboxValueFromGameini("Wii", "Widescreen", EnableWideScreen);
  SetCheckboxValueFromGameini("Video_Stereoscopy", "StereoEFBMonoDepth", MonoDepth);

  IniFile::Section* default_video = GameIniDefault.GetOrCreateSection("Video");

  int iTemp;
  default_video->Get("ProjectionHack", &iTemp);
  default_video->Get("PH_SZNear", &m_PHack_Data.PHackSZNear);
  if (GameIniLocal.GetIfExists("Video", "PH_SZNear", &iTemp))
    m_PHack_Data.PHackSZNear = !!iTemp;
  default_video->Get("PH_SZFar", &m_PHack_Data.PHackSZFar);
  if (GameIniLocal.GetIfExists("Video", "PH_SZFar", &iTemp))
    m_PHack_Data.PHackSZFar = !!iTemp;

  std::string sTemp;
  default_video->Get("PH_ZNear", &m_PHack_Data.PHZNear);
  if (GameIniLocal.GetIfExists("Video", "PH_ZNear", &sTemp))
    m_PHack_Data.PHZNear = sTemp;
  default_video->Get("PH_ZFar", &m_PHack_Data.PHZFar);
  if (GameIniLocal.GetIfExists("Video", "PH_ZFar", &sTemp))
    m_PHack_Data.PHZFar = sTemp;

  IniFile::Section* default_emustate = GameIniDefault.GetOrCreateSection("EmuState");
  default_emustate->Get("EmulationStateId", &iTemp, 0 /*Not Set*/);
  EmuState->SetSelection(iTemp);
  if (GameIniLocal.GetIfExists("EmuState", "EmulationStateId", &iTemp))
    EmuState->SetSelection(iTemp);

  default_emustate->Get("EmulationIssues", &sTemp);
  if (!sTemp.empty())
    EmuIssues->SetValue(StrToWxStr(sTemp));
  if (GameIniLocal.GetIfExists("EmuState", "EmulationIssues", &sTemp))
    EmuIssues->SetValue(StrToWxStr(sTemp));

  EmuIssues->Enable(EmuState->GetSelection() != 0);

  sTemp = "";
  if (!GameIniLocal.GetIfExists("Core", "GPUDeterminismMode", &sTemp))
    GameIniDefault.GetIfExists("Core", "GPUDeterminismMode", &sTemp);

  if (sTemp == "")
    GPUDeterminism->SetSelection(0);
  else if (sTemp == "auto")
    GPUDeterminism->SetSelection(1);
  else if (sTemp == "none")
    GPUDeterminism->SetSelection(2);
  else if (sTemp == "fake-completion")
    GPUDeterminism->SetSelection(3);

  IniFile::Section* default_stereoscopy = GameIniDefault.GetOrCreateSection("Video_Stereoscopy");
  default_stereoscopy->Get("StereoDepthPercentage", &iTemp, 100);
  GameIniLocal.GetIfExists("Video_Stereoscopy", "StereoDepthPercentage", &iTemp);
  DepthPercentage->SetValue(iTemp);
  default_stereoscopy->Get("StereoConvergence", &iTemp, 0);
  GameIniLocal.GetIfExists("Video_Stereoscopy", "StereoConvergence", &iTemp);
  Convergence->SetValue(iTemp);

  PatchList_Load();
  m_ar_code_panel->LoadCodes(GameIniDefault, GameIniLocal);
  m_geckocode_panel->LoadCodes(GameIniDefault, GameIniLocal, m_open_iso->GetGameID());
}
Example #25
0
void FillWithGameNames(wxListBox* game_lbox, const CGameListCtrl& game_list)
{
	for (u32 i = 0 ; auto game = game_list.GetISO(i); ++i)
		game_lbox->Append(StrToWxStr(BuildGameName(*game)));
}
Example #26
0
void CCodeView::OnPopupMenu(wxCommandEvent& event)
{
#if wxUSE_CLIPBOARD
	wxTheClipboard->Open();
#endif

	switch (event.GetId())
	{
		case IDM_GOTOINMEMVIEW:
			// CMemoryDlg::Goto(selection);
			break;

#if wxUSE_CLIPBOARD
		case IDM_COPYADDRESS:
			wxTheClipboard->SetData(new wxTextDataObject(wxString::Format(_T("%08x"), selection)));
			break;

		case IDM_COPYCODE:
			{
				char disasm[256];
				debugger->Disassemble(selection, disasm, 256);
				wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(disasm)));
			}
			break;

		case IDM_COPYHEX:
			{
				char temp[24];
				sprintf(temp, "%08x", debugger->ReadInstruction(selection));
				wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp)));
			}
			break;


		case IDM_COPYFUNCTION:
			{
				Symbol *symbol = symbol_db->GetSymbolFromAddr(selection);
				if (symbol)
				{
					std::string text;
					text = text + symbol->name + "\r\n";
					// we got a function
					u32 start = symbol->address;
					u32 end = start + symbol->size;
					for (u32 addr = start; addr != end; addr += 4)
					{
						char disasm[256];
						debugger->Disassemble(addr, disasm, 256);
						text = text + StringFromFormat("%08x: ", addr) + disasm + "\r\n";
					}
					wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(text)));
				}
			}
			break;
#endif

		case IDM_RUNTOHERE:
			debugger->SetBreakpoint(selection);
			debugger->RunToBreakpoint();
			Refresh();
			break;

		// Insert blr or restore old value
		case IDM_INSERTBLR:
			InsertBlrNop(0);
			Refresh();
			break;
		case IDM_INSERTNOP:
			InsertBlrNop(1);
			Refresh();
			break;

		case IDM_JITRESULTS:
			debugger->ShowJitResults(selection);
			break;

		case IDM_FOLLOWBRANCH:
			{
				u32 dest = AddrToBranch(selection);
				if (dest)
				{
					Center(dest);
					RaiseEvent();
				}
			}
			break;

		case IDM_ADDFUNCTION:
			symbol_db->AddFunction(selection);
			Host_NotifyMapLoaded();
			break;

		case IDM_RENAMESYMBOL:
			{
				Symbol *symbol = symbol_db->GetSymbolFromAddr(selection);
				if (symbol)
				{
					wxTextEntryDialog input_symbol(this, StrToWxStr("Rename symbol:"),
							wxGetTextFromUserPromptStr,
							StrToWxStr(symbol->name));
					if (input_symbol.ShowModal() == wxID_OK)
					{
						symbol->name = WxStrToStr(input_symbol.GetValue());
						Refresh(); // Redraw to show the renamed symbol
					}
					Host_NotifyMapLoaded();
				}
			}
			break;

		case IDM_PATCHALERT:
			break;
	}

#if wxUSE_CLIPBOARD
	wxTheClipboard->Close();
#endif
	event.Skip(true);
}
Example #27
0
void CCodeView::OnPopupMenu(wxCommandEvent& event)
{
#if wxUSE_CLIPBOARD
	wxTheClipboard->Open();
#endif

	switch (event.GetId())
	{
		case IDM_GOTOINMEMVIEW:
			// CMemoryDlg::Goto(selection);
			break;

#if wxUSE_CLIPBOARD
		case IDM_COPYADDRESS:
			wxTheClipboard->SetData(new wxTextDataObject(wxString::Format("%08x", m_selection)));
			break;

		case IDM_COPYCODE:
			{
				std::string disasm = m_debugger->Disassemble(m_selection);
				wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(disasm)));
			}
			break;

		case IDM_COPYHEX:
			{
				std::string temp = StringFromFormat("%08x", m_debugger->ReadInstruction(m_selection));
				wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(temp)));
			}
			break;


		case IDM_COPYFUNCTION:
			{
				Symbol *symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
				if (symbol)
				{
					std::string text;
					text = text + symbol->name + "\r\n";
					// we got a function
					u32 start = symbol->address;
					u32 end = start + symbol->size;
					for (u32 addr = start; addr != end; addr += 4)
					{
						std::string disasm = m_debugger->Disassemble(addr);
						text += StringFromFormat("%08x: ", addr) + disasm + "\r\n";
					}
					wxTheClipboard->SetData(new wxTextDataObject(StrToWxStr(text)));
				}
			}
			break;
#endif

		case IDM_RUNTOHERE:
			m_debugger->SetBreakpoint(m_selection);
			m_debugger->RunToBreakpoint();
			Refresh();
			break;

		// Insert blr or restore old value
		case IDM_INSERTBLR:
			InsertBlrNop(0);
			Refresh();
			break;
		case IDM_INSERTNOP:
			InsertBlrNop(1);
			Refresh();
			break;

		case IDM_JITRESULTS:
			{
				// Propagate back to the parent window and tell it
				// to flip to the JIT tab for the current address.
				wxCommandEvent jit_event(wxEVT_HOST_COMMAND, IDM_UPDATE_JIT_PANE);
				GetEventHandler()->AddPendingEvent(jit_event);
			}
			break;

		case IDM_FOLLOWBRANCH:
			{
				u32 dest = AddrToBranch(m_selection);
				if (dest)
				{
					Center(dest);
					RaiseEvent();
				}
			}
			break;

		case IDM_ADDFUNCTION:
			m_symbol_db->AddFunction(m_selection);
			Host_NotifyMapLoaded();
			break;

		case IDM_RENAMESYMBOL:
			{
				Symbol *symbol = m_symbol_db->GetSymbolFromAddr(m_selection);
				if (symbol)
				{
					wxTextEntryDialog input_symbol(this, _("Rename symbol:"),
							wxGetTextFromUserPromptStr,
							StrToWxStr(symbol->name));
					if (input_symbol.ShowModal() == wxID_OK)
					{
						symbol->name = WxStrToStr(input_symbol.GetValue());
						Refresh(); // Redraw to show the renamed symbol
					}
					Host_NotifyMapLoaded();
				}
			}
			break;

		case IDM_PATCHALERT:
			break;
	}

#if wxUSE_CLIPBOARD
	wxTheClipboard->Close();
#endif
	event.Skip();
}
Example #28
0
void CCodeView::OnPaint(wxPaintEvent& event)
{
	// --------------------------------------------------------------------
	// General settings
	// -------------------------
	wxPaintDC dc(this);
	wxRect rc = GetClientRect();

	dc.SetFont(DebuggerFont);

	wxCoord w,h;
	dc.GetTextExtent(_T("0WJyq"),&w,&h);

	if (h > rowHeight)
		rowHeight = h;

	dc.GetTextExtent(_T("W"),&w,&h);
	int charWidth = w;

	struct branch
	{
		int src, dst, srcAddr;
	};

	branch branches[256];
	int numBranches = 0;
	// TODO: Add any drawing code here...
	int width   = rc.width;
	int numRows = (rc.height / rowHeight) / 2 + 2;
	// ------------

	// --------------------------------------------------------------------
	// Colors and brushes
	// -------------------------
	dc.SetBackgroundMode(wxTRANSPARENT); // the text background
	const wxChar* bgColor = _T("#ffffff");
	wxPen nullPen(bgColor);
	wxPen currentPen(_T("#000000"));
	wxPen selPen(_T("#808080")); // gray
	nullPen.SetStyle(wxTRANSPARENT);
	currentPen.SetStyle(wxSOLID);
	wxBrush currentBrush(_T("#FFEfE8")); // light gray
	wxBrush pcBrush(_T("#70FF70")); // green
	wxBrush bpBrush(_T("#FF3311")); // red

	wxBrush bgBrush(bgColor);
	wxBrush nullBrush(bgColor);
	nullBrush.SetStyle(wxTRANSPARENT);

	dc.SetPen(nullPen);
	dc.SetBrush(bgBrush);
	dc.DrawRectangle(0, 0, 16, rc.height);
	dc.DrawRectangle(0, 0, rc.width, 5);
	// ------------

	// --------------------------------------------------------------------
	// Walk through all visible rows
	// -------------------------
	for (int i = -numRows; i <= numRows; i++)
	{
		unsigned int address = curAddress + i * align;

		int rowY1 = rc.height / 2 + rowHeight * i - rowHeight / 2;
		int rowY2 = rc.height / 2 + rowHeight * i + rowHeight / 2;

		wxString temp = wxString::Format(_T("%08x"), address);
		u32 col = debugger->GetColor(address);
		wxBrush rowBrush(wxColor(col >> 16, col >> 8, col));
		dc.SetBrush(nullBrush);
		dc.SetPen(nullPen);
		dc.DrawRectangle(0, rowY1, 16, rowY2 - rowY1 + 2);

		if (selecting && (address == selection))
			dc.SetPen(selPen);
		else
			dc.SetPen(i == 0 ? currentPen : nullPen);

		if (address == debugger->GetPC())
			dc.SetBrush(pcBrush);
		else
			dc.SetBrush(rowBrush);

		dc.DrawRectangle(16, rowY1, width, rowY2 - rowY1 + 1);
		dc.SetBrush(currentBrush);
		if (!plain)
		{
			dc.SetTextForeground(_T("#600000")); // the address text is dark red
			dc.DrawText(temp, 17, rowY1);
			dc.SetTextForeground(_T("#000000"));
		}

		// If running
		if (debugger->IsAlive())
		{
			char dis[256];
			debugger->Disassemble(address, dis, 256);
			char* dis2 = strchr(dis, '\t');
			char desc[256] = "";

			// If we have a code
			if (dis2)
			{
				*dis2 = 0;
				dis2++;
				// look for hex strings to decode branches
				const char* mojs = strstr(dis2, "0x8");
				if (mojs)
				{
					for (int k = 0; k < 8; k++)
					{
						bool found = false;
						for (int j = 0; j < 22; j++)
						{
							if (mojs[k + 2] == "0123456789ABCDEFabcdef"[j])
								found = true;
						}
						if (!found)
						{
							mojs = nullptr;
							break;
						}
					}
				}
				if (mojs)
				{
					int offs;
					sscanf(mojs + 2, "%08x", &offs);
					branches[numBranches].src = rowY1 + rowHeight / 2;
					branches[numBranches].srcAddr = address / align;
					branches[numBranches++].dst = (int)(rowY1 + ((s64)(u32)offs - (s64)(u32)address) * rowHeight / align + rowHeight / 2);
					sprintf(desc, "-->%s", debugger->GetDescription(offs).c_str());
					dc.SetTextForeground(_T("#600060")); // the -> arrow illustrations are purple
				}
				else
				{
					dc.SetTextForeground(_T("#000000"));
				}

				dc.DrawText(StrToWxStr(dis2), 17 + 17*charWidth, rowY1);
				// ------------
			}

			// Show blr as its' own color
			if (strcmp(dis, "blr"))
				dc.SetTextForeground(_T("#007000")); // dark green
			else
				dc.SetTextForeground(_T("#8000FF")); // purple

			dc.DrawText(StrToWxStr(dis), 17 + (plain ? 1*charWidth : 9*charWidth), rowY1);

			if (desc[0] == 0)
			{
				strcpy(desc, debugger->GetDescription(address).c_str());
			}

			if (!plain)
			{
				dc.SetTextForeground(_T("#0000FF")); // blue

				//char temp[256];
				//UnDecorateSymbolName(desc,temp,255,UNDNAME_COMPLETE);
				if (strlen(desc))
				{
					dc.DrawText(StrToWxStr(desc), 17 + 35 * charWidth, rowY1);
				}
			}

			// Show red breakpoint dot
			if (debugger->IsBreakpoint(address))
			{
				dc.SetBrush(bpBrush);
				dc.DrawRectangle(2, rowY1 + 1, 11, 11);
			}
		}
	} // end of for
	// ------------

	// --------------------------------------------------------------------
	// Colors and brushes
	// -------------------------
	dc.SetPen(currentPen);

	for (int i = 0; i < numBranches; i++)
	{
		int x = 17 + 49 * charWidth + (branches[i].srcAddr % 9) * 8;
		_MoveTo(x-2, branches[i].src);

		if (branches[i].dst < rc.height + 400 && branches[i].dst > -400)
		{
			_LineTo(dc, x+2, branches[i].src);
			_LineTo(dc, x+2, branches[i].dst);
			_LineTo(dc, x-4, branches[i].dst);

			_MoveTo(x, branches[i].dst - 4);
			_LineTo(dc, x-4, branches[i].dst);
			_LineTo(dc, x+1, branches[i].dst+5);
		}
		//else
		//{
			// This can be re-enabled when there is a scrollbar or
			// something on the codeview (the lines are too long)

			//_LineTo(dc, x+4, branches[i].src);
			//_MoveTo(x+2, branches[i].dst-4);
			//_LineTo(dc, x+6, branches[i].dst);
			//_LineTo(dc, x+1, branches[i].dst+5);
		//}

		//_LineTo(dc, x, branches[i].dst+4);
		//_LineTo(dc, x-2, branches[i].dst);
	}
	// ------------
}
static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
{
	switch (g->control_group->type)
	{
	case GROUP_TYPE_TILT :
	case GROUP_TYPE_STICK :
	case GROUP_TYPE_CURSOR :
	{
		// this is starting to be a mess combining all these in one case

		ControlState x = 0, y = 0, z = 0;

		switch (g->control_group->type)
		{
		case GROUP_TYPE_STICK :
			((ControllerEmu::AnalogStick*)g->control_group)->GetState(&x, &y);
			break;
		case GROUP_TYPE_TILT :
			((ControllerEmu::Tilt*)g->control_group)->GetState(&x, &y);
			break;
		case GROUP_TYPE_CURSOR :
			((ControllerEmu::Cursor*)g->control_group)->GetState(&x, &y, &z);
			break;
		}

		// ir cursor forward movement
		if (GROUP_TYPE_CURSOR == g->control_group->type)
		{
			if (z)
			{
				dc.SetPen(*wxRED_PEN);
				dc.SetBrush(*wxRED_BRUSH);
			}
			else
			{
				dc.SetPen(*wxGREY_PEN);
				dc.SetBrush(*wxGREY_BRUSH);
			}
			dc.DrawRectangle(0, 31 - z*31, 64, 2);
		}

		// octagon for visual aid for diagonal adjustment
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxWHITE_BRUSH);
		if (GROUP_TYPE_STICK == g->control_group->type)
		{
			// outline and fill colors
			wxBrush LightGrayBrush("#dddddd");
			wxPen LightGrayPen("#bfbfbf");
			dc.SetBrush(LightGrayBrush);
			dc.SetPen(LightGrayPen);

			// polygon offset
			ControlState max
				, diagonal
				, box = 64
				, d_of = box / 256.0
				, x_of = box / 2.0;

			if (g->control_group->name == "Main Stick")
			{
				max = (87.0 / 127.0) * 100;
				diagonal = (55.0 / 127.0) * 100;
			}
			else if (g->control_group->name == "C-Stick")
			{
				max = (74.0 / 127.0) * 100;
				diagonal = (46.0 / 127.0) * 100;
			}
			else
			{
				max = (82.0 / 127.0) * 100;
				diagonal = (58.0 / 127.0) * 100;
			}

			// polygon corners
			wxPoint Points[8];
			Points[0].x = (int)(0.0 * d_of + x_of); Points[0].y = (int)(max * d_of + x_of);
			Points[1].x = (int)(diagonal * d_of + x_of); Points[1].y = (int)(diagonal * d_of + x_of);
			Points[2].x = (int)(max * d_of + x_of); Points[2].y = (int)(0.0 * d_of + x_of);
			Points[3].x = (int)(diagonal * d_of + x_of); Points[3].y = (int)(-diagonal * d_of + x_of);
			Points[4].x = (int)(0.0 * d_of + x_of); Points[4].y = (int)(-max * d_of + x_of);
			Points[5].x = (int)(-diagonal * d_of + x_of); Points[5].y = (int)(-diagonal * d_of + x_of);
			Points[6].x = (int)(-max * d_of + x_of); Points[6].y = (int)(0.0 * d_of + x_of);
			Points[7].x = (int)(-diagonal * d_of + x_of); Points[7].y = (int)(diagonal * d_of + x_of);

			// draw polygon
			dc.DrawPolygon(8, Points);
		}
		else
		{
			dc.DrawRectangle(16, 16, 32, 32);
		}

		if (GROUP_TYPE_CURSOR != g->control_group->type)
		{
			// deadzone circle
			dc.SetBrush(*wxLIGHT_GREY_BRUSH);
			dc.DrawCircle(32, 32, g->control_group->settings[SETTING_DEADZONE]->value * 32);
		}

		// raw dot
		{
		ControlState xx, yy;
		xx = g->control_group->controls[3]->control_ref->State();
		xx -= g->control_group->controls[2]->control_ref->State();
		yy = g->control_group->controls[1]->control_ref->State();
		yy -= g->control_group->controls[0]->control_ref->State();

		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		DrawCoordinate(dc, xx, yy);
		}

		// adjusted dot
		if (x != 0 && y != 0)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			// XXX: The adjusted values flip the Y axis to be in the format
			// the Wii expects. Should this be in WiimoteEmu.cpp instead?
			DrawCoordinate(dc, x, -y);
		}
	}
	break;
	case GROUP_TYPE_FORCE :
	{
		ControlState raw_dot[3];
		ControlState adj_dot[3];
		const ControlState deadzone = g->control_group->settings[0]->value;

		// adjusted
		((ControllerEmu::Force*)g->control_group)->GetState(adj_dot);

		// raw
		for (unsigned int i=0; i<3; ++i)
		{
			raw_dot[i] = (g->control_group->controls[i*2 + 1]->control_ref->State() -
				      g->control_group->controls[i*2]->control_ref->State());
		}

		// deadzone rect for forward/backward visual
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		dc.SetPen(*wxLIGHT_GREY_PEN);
		int deadzone_height = deadzone * VIS_BITMAP_SIZE;
		DrawCenteredRectangle(dc, 0, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE, deadzone_height);

#define LINE_HEIGHT 2
		int line_y;

		// raw forward/background line
		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		line_y = VIS_COORD(raw_dot[2]);
		DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);

		// adjusted forward/background line
		if (adj_dot[2] != 0.0)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			line_y = VIS_COORD(adj_dot[2]);
			DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, line_y, VIS_BITMAP_SIZE, LINE_HEIGHT);
		}

#define DEADZONE_RECT_SIZE 32

		// empty deadzone square
		dc.SetBrush(*wxWHITE_BRUSH);
		dc.SetPen(*wxLIGHT_GREY_PEN);
		DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, DEADZONE_RECT_SIZE, DEADZONE_RECT_SIZE);

		// deadzone square
		dc.SetBrush(*wxLIGHT_GREY_BRUSH);
		int dz_size = (deadzone * DEADZONE_RECT_SIZE);
		DrawCenteredRectangle(dc, VIS_BITMAP_SIZE / 2, VIS_BITMAP_SIZE / 2, dz_size, dz_size);

		// raw dot
		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		DrawCoordinate(dc, raw_dot[1], raw_dot[0]);

		// adjusted dot
		if (adj_dot[1] != 0 && adj_dot[0] != 0)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			DrawCoordinate(dc, adj_dot[1], adj_dot[0]);
		}

	}
	break;
	case GROUP_TYPE_BUTTONS :
	{
		const unsigned int button_count = ((unsigned int)g->control_group->controls.size());

		// draw the shit
		dc.SetPen(*wxGREY_PEN);

		unsigned int * const bitmasks = new unsigned int[ button_count ];
		for (unsigned int n = 0; n<button_count; ++n)
			bitmasks[n] = (1 << n);

		unsigned int buttons = 0;
		((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);

		for (unsigned int n = 0; n<button_count; ++n)
		{
			if (buttons & bitmasks[n])
			{
				dc.SetBrush(*wxRED_BRUSH);
			}
			else
			{
				unsigned char amt = 255 - g->control_group->controls[n]->control_ref->State() * 128;
				dc.SetBrush(wxBrush(wxColour(amt, amt, amt)));
			}
			dc.DrawRectangle(n * 12, 0, 14, 12);

			// text
			const std::string name = g->control_group->controls[n]->name;
			// bit of hax so ZL, ZR show up as L, R
			dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1);
		}

		delete[] bitmasks;

	}
	break;
	case GROUP_TYPE_TRIGGERS :
	{
		const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size()));

		// draw the shit
		dc.SetPen(*wxGREY_PEN);
		ControlState deadzone =  g->control_group->settings[0]->value;

		ControlState* const trigs = new ControlState[trigger_count];
		((ControllerEmu::Triggers*)g->control_group)->GetState(trigs);

		for (unsigned int n = 0; n < trigger_count; ++n)
		{
			ControlState trig_r = g->control_group->controls[n]->control_ref->State();

			// outline
			dc.SetPen(*wxGREY_PEN);
			dc.SetBrush(*wxWHITE_BRUSH);
			dc.DrawRectangle(0, n*12, 64, 14);

			// raw
			dc.SetBrush(*wxGREY_BRUSH);
			dc.DrawRectangle(0, n*12, trig_r*64, 14);

			// deadzone affected
			dc.SetBrush(*wxRED_BRUSH);
			dc.DrawRectangle(0, n*12, trigs[n]*64, 14);

			// text
			dc.DrawText(StrToWxStr(g->control_group->controls[n]->name), 3, n*12 + 1);
		}

		delete[] trigs;

		// deadzone box
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.DrawRectangle(0, 0, deadzone*64, trigger_count*14);

	}
	break;
	case GROUP_TYPE_MIXED_TRIGGERS :
	{
		const unsigned int trigger_count = ((unsigned int)(g->control_group->controls.size() / 2));

		// draw the shit
		dc.SetPen(*wxGREY_PEN);
		ControlState thresh = g->control_group->settings[0]->value;

		for (unsigned int n = 0; n < trigger_count; ++n)
		{
			dc.SetBrush(*wxRED_BRUSH);
			ControlState trig_d = g->control_group->controls[n]->control_ref->State();

			ControlState trig_a = trig_d > thresh ? 1
				: g->control_group->controls[n+trigger_count]->control_ref->State();

			dc.DrawRectangle(0, n*12, 64+20, 14);
			if (trig_d <= thresh)
				dc.SetBrush(*wxWHITE_BRUSH);
			dc.DrawRectangle(trig_a*64, n*12, 64+20, 14);
			dc.DrawRectangle(64, n*12, 32, 14);

			// text
			dc.DrawText(StrToWxStr(g->control_group->controls[n+trigger_count]->name), 3, n*12 + 1);
			dc.DrawText(StrToWxStr(std::string(1, g->control_group->controls[n]->name[0])), 64 + 3, n*12 + 1);
		}

		// threshold box
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.DrawRectangle(thresh*64, 0, 128, trigger_count*14);

	}
	break;
	case GROUP_TYPE_SLIDER:
	{
		const ControlState deadzone = g->control_group->settings[0]->value;

		ControlState state = g->control_group->controls[1]->control_ref->State() - g->control_group->controls[0]->control_ref->State();
		dc.SetPen(*wxGREY_PEN);
		dc.SetBrush(*wxGREY_BRUSH);
		dc.DrawRectangle(31 + state * 30, 0, 2, 14);

		ControlState adj_state;
		((ControllerEmu::Slider*)g->control_group)->GetState(&adj_state);
		if (state)
		{
			dc.SetPen(*wxRED_PEN);
			dc.SetBrush(*wxRED_BRUSH);
			dc.DrawRectangle(31 + adj_state * 30, 0, 2, 14);
		}

		// deadzone box
		dc.SetPen(*wxLIGHT_GREY_PEN);
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.DrawRectangle(32 - deadzone * 32, 0, deadzone * 64, 14);
	}
	break;
	default:
	break;
	}
}
Example #30
0
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label)
	: PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(label)), wxDefaultPosition))
	, value(_value)
{
	UpdateGUI();
}