//--------------------------------------------------------------------------- void TPrepareBitDlg::UpdateView(bool needToCreateChBx) // add checkbox to view screen { m_wasCancelled = false; if(needToCreateChBx == true) { for(unsigned i = 0; i < m_attributesVector.size(); i++) { AddCheckBox(m_attributesVector[i],i); } } }
/** * Konstruktor von @p iwSettings. * * @author NastX */ iwSettings::iwSettings(dskGameInterface* gameDesktop) : IngameWindow(CGI_SETTINGS, 0xFFFF, 0xFFFF, 370, 172, _("Settings"), LOADER.GetImageN("resource", 41)), gameDesktop(gameDesktop) { AddText( 46, 15, 40, _("Fullscreen resolution:"), COLOR_YELLOW, 0, NormalFont); AddText( 47, 15, 85, _("Mode:"), COLOR_YELLOW, 0, NormalFont); AddCheckBox(4, 200, 124, 150, 26, TC_GREY, _("Statistics Scale"), NormalFont, false); GetCtrl<ctrlCheck>(4)->SetCheck(SETTINGS.ingame.scale_statistics); // "Vollbild" ctrlOptionGroup* optiongroup = AddOptionGroup(10, ctrlOptionGroup::CHECK, scale); optiongroup = AddOptionGroup(3, ctrlOptionGroup::CHECK, scale); optiongroup->AddTextButton(1, 200, 70, 150, 22, TC_GREY, _("Fullscreen"), NormalFont); optiongroup->AddTextButton(2, 200, 95, 150, 22, TC_GREY, _("Windowed"), NormalFont); // "Vollbild" setzen optiongroup = GetCtrl<ctrlOptionGroup>(3); optiongroup->SetSelection( (SETTINGS.video.fullscreen ? 1 : 2) ); VIDEODRIVER.ListVideoModes(video_modes); // "Auflösung" AddComboBox(0, 200, 35, 150, 22, TC_GREY, NormalFont, 110); // Und zu der Combobox hinzufügen for(unsigned i = 0; i < video_modes.size(); ++i) { // >=800x600, alles andere macht keinen Sinn if(video_modes[i].width >= 800 && video_modes[i].height >= 600) { char str[64]; sprintf(str, "%ux%u", video_modes[i].width, video_modes[i].height); GetCtrl<ctrlComboBox>(0)->AddString(str); // Ist das die aktuelle Auflösung? Dann selektieren if(video_modes[i].width == SETTINGS.video.fullscreen_width && video_modes[i].height == SETTINGS.video.fullscreen_height) GetCtrl<ctrlComboBox>(0)->SetSelection(i); } else { video_modes.erase(video_modes.begin() + i); --i; } } }
iwMapDebug::iwMapDebug(GameWorldViewer& gwv): IngameWindow(CGI_MAP_DEBUG, 0xFFFF, 0xFFFF, 300, 200, _("Map Debug"), LOADER.GetImageN("resource", 41)), gwv(gwv), printer(new DebugPrinter(gwv)) { gwv.GetView()->SetDebugNodePrinter(printer); ctrlCheck* cbShowCoords = AddCheckBox(0, 15, 30, 250, 20, TC_GREY, _("Show coordinates"), NormalFont); cbShowCoords->SetCheck(true); ctrlComboBox* data = AddComboBox(1, 15, 60, 250, 20, TC_GREY, NormalFont, 100); data->AddString(_("Nothing")); data->AddString(_("Reserved")); data->AddString(_("Altitude")); data->AddString(_("Resources")); data->AddString(_("Sea Id")); data->SetSelection(1); printer->showCoords = cbShowCoords->GetCheck(); printer->showDataIdx = data->GetSelection(); }
// We now have a group of tie functions which are generic in the type // they bind to (i.e. WrappedType). // The type specific versions are much shorter and are later // in this file. wxCheckBox * ShuttleGuiBase::TieCheckBox(const wxString &Prompt, WrappedType & WrappedRef) { // The Add function does a UseUpId(), so don't do it here in that case. if( mShuttleMode == eIsCreating ) return AddCheckBox( Prompt, WrappedRef.ReadAsString()); UseUpId(); wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg); wxCheckBox * pCheckBox = wxDynamicCast(pWnd, wxCheckBox); switch( mShuttleMode ) { // IF setting internal storage from the controls. case eIsGettingFromDialog: { wxASSERT( pCheckBox ); WrappedRef.WriteToAsBool( pCheckBox->GetValue() ); } break; case eIsSettingToDialog: { wxASSERT( pCheckBox ); pCheckBox->SetValue( WrappedRef.ReadAsBool() ); } break; // IF Saving settings to external storage... // or IF Getting settings from external storage. case eIsSavingViaShuttle: case eIsGettingViaShuttle: DoDataShuttle( Prompt, WrappedRef ); break; default: wxASSERT( false ); break; } return pCheckBox; }
bool wxTreeMultiXmlMapper::DoCreateControls(TiXmlElement *cat, wxTreeMultiItem &pitem, wxWindow *pwnd, wxSizer *szr) { bool allOk = true; wxCHECK(cat, false); wxString value; wxWindow *wnd = 0; // go through all siblings of this TiXmlNode *node = cat->FirstChild(); while(node && allOk) { // cast to element. When it is an element, work this TiXmlElement *el = node->ToElement(); if(el) { value = el->Value(); // when we are dealing with a <row> element, we introduce a wxBoxSizer + panel // to add more on one row if(value.IsSameAs(XMLMAP_TAG_ROW, false)) { // we are in a row. All elements inside need to be parent // of this element, and we use a sizer to layout wxPanel *pnl = new wxPanel((pwnd != 0 ? pwnd : m_ctrl), -1); wxBoxSizer *bsz = new wxBoxSizer(wxHORIZONTAL); allOk = DoCreateControls(el, pitem, pnl, bsz); if(allOk) { // ok now we have all added elements, set the sizer and // add the item when we have no parent control nomore pnl->SetSizerAndFit(bsz); if(pwnd == 0) { // add the window m_ctrl->AppendWindow(pitem, pnl); } } else delete bsz; } else if(value.IsSameAs(XMLMAP_TAG_CATEGORY, false)) // is it an <category> element? { if(!pwnd) { // only allow when we have no parent window wxTreeMultiItem item = AddCategory(el, pitem); allOk = DoCreateControls(el, item, 0, 0); } else { // we do not allow a category inside another window! // so we report this as an error wxLogError(_("Cannot have a <" XMLMAP_TAG_CATEGORY "> inside <" XMLMAP_TAG_ROW "> tags!")); allOk = false; } } else if(value.IsSameAs(XMLMAP_TAG_CHECKBOX, false)) // is it a <checkbox> element? wnd = AddCheckBox(el, (pwnd != 0 ? pwnd : m_ctrl)); else if(value.IsSameAs(XMLMAP_TAG_BUTTON, false)) // is it a <button> element? wnd = AddButton(el, (pwnd != 0 ? pwnd : m_ctrl)); else // we encountered a strange element, just ignore allOk = true; // if we have a window to add, do this. if(wnd) { // add to sizer when there is one, else // do not add but trust the parent will be added if(szr) szr->Add(wnd, 0, wxALIGN_CENTER_VERTICAL); else m_ctrl->AppendWindow(pitem, wnd); allOk = (wnd != 0); wnd = 0; } } // get next sibling on this level if(allOk) node = node->NextSibling(); } return allOk; }
void wxZEditNode::BuildInterface(wxGraphNode *pNode) { mEditingNode = pNode; BeginPanel(); if (mEditingNode) { mNodeName = mEditingNode->GetFunctionName(); AddFolder(_("Node")); AddTextEdit(_("Name"), &mNodeName, 200); #if 0 AddStatic("Comments"); AddScriptEdit(pNode->GetComment(), 2); if (pNode->GetType() == GNT_STATE) { AddFolder("Properties"); } #endif if (pNode->GetType() == GNT_MESSAGE) { AddFolder(_("Source code")); AddScriptEdit(pNode->GetCode(pNode->GetSubItem()), 2); } if (mEditingNode->GetType() == GNT_STATE) { wxString info; info = mNodeName+_(" > "); info += ((wxGraphNodeState*)mEditingNode)->mCurSelectedButton; SetScriptToEdit(info, pNode->GetCode(pNode->GetSubItem())); } } else { // editing tab extern wxNotebook * myNotebook; mNodeName = myNotebook->GetPageText(myNotebook->GetSelection()); AddFolder(_("FSM")); AddTextEdit(_("Name"), &mNodeName, 199); AddCheckBox(_("Add Raknet packet support"), &mScrollV->mbRaknetMessage); AddCheckBox(_("Tick has time parameter"), &mScrollV->mbTickHasTime); AddTextEdit(_("State base"), &mScrollV->mStateEnumBase); AddTextEdit(_("Message base"), &mScrollV->mMessageEnumBase); AddTextEdit(_("Output"), &mScrollV->mOutputFileName); std::vector<wxString> mStateList; mScrollV->FillNodeList(mStateList, GNT_STATE); if (!mStateList.empty()) { wxString mInitialStatesList; for (unsigned int i=0;i<mStateList.size()-1;i++) { mInitialStatesList += mStateList[i]+_("|"); } mInitialStatesList += mStateList[mStateList.size()-1]; if (mScrollV->mInitialState > (mStateList.size()-1) ) mScrollV->mInitialState = 0; AddCombo(_("Initial State"), mInitialStatesList.c_str(), &mScrollV->mInitialState); } AddFolder(_("Code")); AddStatic(_("Includes")); AddScriptEdit(mScrollV->GetIncludes(), 14); AddStatic(_("Member Variables")); AddScriptEdit(mScrollV->GetMemberVariables(), 14); AddStatic(_("Members Init")); AddScriptEdit(mScrollV->GetMembersInit(), 14); extern wxScriptEditPanel *mEditScriptPanel; mEditScriptPanel->SetScriptToEdit(wxT(""), NULL); } EndPanel(); }
// // EXAMPLES: // m_hWnd, _T("Message \r\nDisplay it"), _T("Captain"),MB_DEFBUTTON2, FALSE, TRUE, // 5, NULL, _T("OK\nCancel"), // RGB(255,0,0), RGB(255,255,255), NULL, 10 // // Return Value; // IDOK, IDCANCEL, IDCUSTOM1, IDCUSTOM2, IDCUSTOM3 u32 MessageBox_i(HWND hWnd, // if NULL, use the active window LPCTSTR pszText, // Pointer to a null-terminated string that contains the message to display. LPCTSTR pszCaption, // Pointer to a null-terminated string that is used in the title bar of the message box. UINT nStyle, // MB_TOPMOST, MB_SETFOREGROUND, MB_SYSTEMMODAL,MB_ICONSTOP,MB_ICONINFOMATION, MB_ICONINFORMATION,MB_ICONWARNING,MB_ICONERROR bool bCheckBox, // if need check box, return IDCHECKBOX u32 ulDisplayTimeOut, // UINT uDefaultButton, // causes specific info(like timeout) to display on, from MB_DEFBUTTON1 to MB_DEFBUTTON3 HICON hIcon, // if NULL use system default icon. TCHAR szButtons[BUTTONS_TEXT_MAX_LEN], // button string, seprate by '\n' like _T("OK\nCancel"), the last button is checkbox button if bCheckBox=TRUE. LPCTSTR pszIdentifier, // = NULL, used for CheckBox if need and save to registry and check it next time. COLORREF crText, // MESSAGE_BOX_VALUE_INVALID // message text color COLORREF crBackground, // =MESSAGE_BOX_VALUE_INVALID // message background LPCTSTR pszFaceName, // NULL INT32 nFontSize // =10 ) { UINT32 ret = 0; CDlgBoxItem m_pDlgItemArray[MaxItems]; HWND m_hWndOwner = hWnd; // handle of owner window TCHAR szButtonTxtSeq[IDCUST_NUM][DEFAULT_BUTTON_TXT_LEN] = {{_T("")}, }; TCHAR szCheckButtonTxt[DEFAULT_BUTTON_TXT_LEN]; szCheckButtonTxt[0] = _T('\0'); // check input parameters. if (szButtons[0] == _T('\0')) { return -1; } CDlgBoxEntry* pDlgBox = new CDlgBoxEntry; if(pDlgBox == NULL) { return -2; } pDlgBox->m_bNeedCheck = FALSE; if(pszIdentifier) { DWORD dwData = ReadRegistry(pszIdentifier); // Note: dwData will be 0 if either ReadRegistry or // GetPrivateProfileString fail to find key if (LOWORD(dwData) == IDCHECKBOX) { pDlgBox->m_bNeedCheck = HIWORD(dwData); } } // Save to process in MessageBoxProc pDlgBox->m_crText = crText; pDlgBox->m_crBackground = crBackground; pDlgBox->m_nStyle = nStyle; if(pszIdentifier) { lstrcpyn(pDlgBox->m_szIdentifier, pszIdentifier, COUNTOF(pDlgBox->m_szIdentifier)); } if (crBackground == MESSAGE_BOX_VALUE_INVALID) crBackground = ::GetSysColor(COLOR_WINDOW); if (crBackground != MESSAGE_BOX_VALUE_INVALID) pDlgBox->m_hBackgroundBrush = ::CreateSolidBrush(crBackground); // translate dialog units to pixels int nBaseunitX = LOWORD(GetDialogBaseUnits()); int nBaseunitY = HIWORD(GetDialogBaseUnits()); int m_nButtonWidth = MulDiv(ButtonWidth, nBaseunitX, 4); // button width in pixels int m_nButtonHeight = MulDiv(ButtonHeight, nBaseunitY, 8); int m_nButtonTimeoutExtraWidth = MulDiv(ButtonTimeoutExtraWidth, nBaseunitX, 4); // timeout button extra width in pixels int m_nDoNotAskAgainHeight = MulDiv(CHECKBOXHEIGHT, nBaseunitY, 8); // checkbox height in pixels // Specify the default button to change dispaly text for timeout switch (uDefaultButton) { case MB_DEFBUTTON1 : pDlgBox->m_nDefaultButtonId = IDCUSTOM1; break; case MB_DEFBUTTON2 : pDlgBox->m_nDefaultButtonId = IDCUSTOM2; break; case MB_DEFBUTTON3 : pDlgBox->m_nDefaultButtonId = IDCUSTOM3; break; case MB_DEFBUTTON4 : pDlgBox->m_nDefaultButtonId = IDCHECKBOX; break; default: pDlgBox->m_nDefaultButtonId = 0; break; } // m_szDefaultButton is used to save text for timeout option pDlgBox->m_szDefaultButton[0] = _T('\0'); // get dc for drawing HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL); pDlgBox->m_hFont = CreatFont_i(pszFaceName, nFontSize, FALSE, FALSE); HFONT hOldFont = (HFONT)::SelectObject(hdc, pDlgBox->m_hFont); int button_width = m_nButtonWidth; pDlgBox->m_nTimeoutSeconds = ulDisplayTimeOut; int nMaxWidth = (::GetSystemMetrics(SM_CXSCREEN) / 2) + 80; if (nStyle & MB_ICONMASK) nMaxWidth -= GetSystemMetrics(SM_CXICON) + 2*SpacingSize; SetRect(&pDlgBox->m_msgrect, 0, 0, nMaxWidth, nMaxWidth); // get output size of message text ::DrawText(hdc, pszText, -1, &pDlgBox->m_msgrect, DT_LEFT | DT_NOPREFIX | DT_WORDBREAK | DT_CALCRECT | DT_EXPANDTABS); int nMessageHeight = pDlgBox->m_msgrect.Height(); // get height of a single line SIZE nLineSize; ::GetTextExtentPoint32(hdc, _T("My"), 2, &nLineSize); pDlgBox->m_msgrect.right += 12; pDlgBox->m_msgrect.bottom += 5; pDlgBox->m_msgrect.left = 2 * SpacingSize; pDlgBox->m_msgrect.top = 2 * SpacingSize; pDlgBox->m_msgrect.right += 2 * SpacingSize; pDlgBox->m_msgrect.bottom += 3 * SpacingSize; // client rect CRectX mbrect; SetRect(&mbrect, 0, 0,pDlgBox->m_msgrect.Width() + (2 * SpacingSize), pDlgBox->m_msgrect.Height() + (2 * SpacingSize)); if (mbrect.Height() < MinimalHeight) mbrect.bottom = MinimalHeight; /////////////////////////////////////////////////////////////////////////// DLGTEMPLATE m_dlgTempl = {0, }; // message box dialog template // initialize the DLGTEMPLATE structure m_dlgTempl.x = 0; m_dlgTempl.y = 0; m_dlgTempl.cdit = 0; m_dlgTempl.style = WS_CAPTION | WS_VISIBLE | WS_SYSMENU | WS_POPUP | DS_MODALFRAME | DS_CENTER; m_dlgTempl.dwExtendedStyle = 0; if (nStyle & MB_SYSTEMMODAL) m_dlgTempl.style |= DS_SYSMODAL; if(hIcon == NULL) { if (nStyle & MB_ICONMASK) { LPTSTR lpIcon = (LPTSTR)IDI_EXCLAMATION; switch (nStyle & MB_ICONMASK) { case MB_ICONEXCLAMATION: lpIcon = (LPTSTR)IDI_EXCLAMATION; break; case MB_ICONHAND: lpIcon = (LPTSTR)IDI_HAND; break; case MB_ICONQUESTION: lpIcon = (LPTSTR)IDI_QUESTION; break; case MB_ICONASTERISK: lpIcon = (LPTSTR)IDI_ASTERISK; break; } if (lpIcon) pDlgBox->m_hIcon = ::LoadIcon(NULL, lpIcon); } } else { pDlgBox->m_hIcon = hIcon; } // Set Icon if (pDlgBox->m_hIcon) { int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); int icon_x = SpacingSize; int icon_y = SpacingSize; pDlgBox->m_msgrect.left += cxIcon + icon_x; pDlgBox->m_msgrect.right += cxIcon + icon_x; mbrect.right = pDlgBox->m_msgrect.right + SpacingSize; CRectX iconrect; SetRect(&iconrect, icon_x, icon_y, icon_x + cxIcon + 2, icon_y + cyIcon + 2); m_pDlgItemArray[m_dlgTempl.cdit++].AddItem(STATICTEXT, IconControlId, &iconrect, _T("")); // Set ICON control. } // Mesage control m_pDlgItemArray[m_dlgTempl.cdit++].AddItem(STATICTEXT /*EDITCONTROL*/, MessageControlId, &pDlgBox->m_msgrect, pszText); pDlgBox->m_nMessageId = MessageControlId; // process buttons int cItems = 0; int nWidthCustomButtons = 0; TCHAR* pszLastBtn = NULL; // process custom buttons TCHAR szCustomButtons[BUTTONS_TEXT_MAX_LEN]; lstrcpyn(szCustomButtons, szButtons, BUTTONS_TEXT_MAX_LEN); int i = 0; TCHAR * cp = _tcstok(szCustomButtons, _T("\n")); while (cp != NULL) { // Find the next token in a string. if(i < IDCUST_NUM) { szButtonTxtSeq[i][0] = _T('\0'); lstrcpyn(szButtonTxtSeq[i], cp, DEFAULT_BUTTON_TXT_LEN); } cp = _tcstok(NULL, _T("\n")); i++; } cItems = i; cItems = min(cItems, IDCUST_NUM); pDlgBox->m_bCheckBox = bCheckBox; pDlgBox->m_nReturnValueCheckBox = FALSE; if(bCheckBox) { szCheckButtonTxt[0] = _T('\0'); int k = cItems-1; if(k>=0 && k<IDCUST_NUM) { lstrcpyn(szCheckButtonTxt, szButtonTxtSeq[k], sizeof(szCheckButtonTxt)); szButtonTxtSeq[k][0] = _T('\0'); } } // Calculate Button width. i = 0; while ( (i<IDCUST_NUM) && (szButtonTxtSeq[i][0] != _T('\0')) ) { // Find the next token in a string. SIZE size; ::GetTextExtentPoint32(hdc, szButtonTxtSeq[i], lstrlen(szButtonTxtSeq[i]), &size); int w = size.cx + 20; w = (w > button_width) ? w : button_width; // allow for wider buttons if timeout specified if (ulDisplayTimeOut) w += m_nButtonTimeoutExtraWidth; nWidthCustomButtons += w; i++; } i = 0; CRectX iconrect; SetRect(&iconrect, 0, 0, 0, 0); int y = 0; int x = 0; CRectX buttonrow; y = (pDlgBox->m_msgrect.bottom > iconrect.bottom) ? pDlgBox->m_msgrect.bottom : iconrect.bottom; y += SpacingBetweenMessageAndButtons; if (pDlgBox->m_hIcon || pDlgBox->m_hBackgroundBrush) y += 9; int nTotalButtonWidth = nWidthCustomButtons + (ButtonSpacing * (cItems-1)); SetRect(&buttonrow, 0, y, nTotalButtonWidth, y + m_nButtonHeight); int nCheckBoxWidth = 0; // get checkbox width if (szCheckButtonTxt[0] != _T('\0')) { nCheckBoxWidth = m_nDoNotAskAgainHeight; // use height as width of box SIZE size = {0, }; ::GetTextExtentPoint32(hdc, szCheckButtonTxt, lstrlen(szCheckButtonTxt), &size); int w = size.cx + 20; w = (w > button_width) ? w : button_width; nCheckBoxWidth += w; } mbrect.bottom = buttonrow.bottom + BottomMargin; int bw = buttonrow.Width(); int bleft = 2 * SpacingSize; int bright = bleft + bw; if (mbrect.right <= (bright + (2 * SpacingSize))) mbrect.right = bright + (2 * SpacingSize); if (mbrect.Width() < nCheckBoxWidth) mbrect.right = bleft + nCheckBoxWidth; x = (mbrect.Width() - bw) / 2; y = buttonrow.top; if (m_bRightJustifyButtons) { x = mbrect.right - nTotalButtonWidth - 2*SpacingSize; } CRectX rect; ////////////////////////////////////////////////////////////////////////// // Add buttons i = 0; while ( (i<IDCUST_NUM) && (szButtonTxtSeq[i][0] != _T('\0')) ) { SIZE size; ::GetTextExtentPoint32(hdc, szButtonTxtSeq[i], lstrlen(szButtonTxtSeq[i]), &size); int w = size.cx + 20; w = (w > button_width) ? w : button_width; // allow for wider buttons if timeout specified if (ulDisplayTimeOut) w += m_nButtonTimeoutExtraWidth; rect.SetRect(x, y, x + w, y + m_nButtonHeight); m_pDlgItemArray[m_dlgTempl.cdit].AddItem(BUTTON, IDCUSTOM1 + i, &rect, szButtonTxtSeq[i]); m_dlgTempl.cdit++; x += w + ButtonSpacing; i++; } /////////////////////////////////////////////////////////////////////////// // add checkbox if (szCheckButtonTxt[0] != _T('\0')) { CRectX checkboxrect; SetRect(&checkboxrect, 0, 0, nCheckBoxWidth, m_nDoNotAskAgainHeight); AddCheckBox(x, y, rect, mbrect, buttonrow, checkboxrect, szCheckButtonTxt, m_nButtonHeight, m_nDoNotAskAgainHeight,m_pDlgItemArray,m_dlgTempl); } if (buttonrow.bottom >= mbrect.bottom) mbrect.bottom = buttonrow.bottom + (2 * SpacingSize); if (mbrect.right < (buttonrow.right + (2 * SpacingSize))) mbrect.right = buttonrow.right + (2 * SpacingSize); m_dlgTempl.x = 0; m_dlgTempl.y = 0; m_dlgTempl.cx = (short)((mbrect.Width() * 4) / nBaseunitX); m_dlgTempl.cy = (short)((mbrect.Height() * 8) / nBaseunitY); ::SelectObject(hdc, hOldFont); ::DeleteDC(hdc); ///////////////////////////////////////////////////////////////////////// // The first step is to allocate memory to define the dialog. // The information to be stored in the allocated buffer is the following: // // 1. DLGTEMPLATE structure // typedef struct // { // DWORD style; // DWORD dwExtendedStyle; // WORD cdit; // short x; // short y; // short cx; // short cy; // } DLGTEMPLATE; // 2. 0x0000 (Word) indicating the dialog has no menu // 3. 0x0000 (Word) Let windows assign default class to the dialog // 4. (Caption) Null terminated unicode string // 5. 0x000B (size of the font to be used) // 6. "MS Sans Serif" (name of the typeface to be used) // 7. DLGITEMTEMPLATE structure for the button (HAS TO BE DWORD ALIGNED) // typedef struct // { // DWORD style; // DWORD dwExtendedStyle; // short x; // short y; // short cx; // short cy; // WORD id; // } DLGITEMTEMPLATE; // 8. 0x0080 to indicate the control is a button // 9. (Title). Unicode null terminated string with the caption // 10. 0x0000 0 extra bytes of data for this control // 11. DLGITEMTEMPLATE structure for the Static Text (HAS TO BE DWORD ALIGNED) // 12. 0x0081 to indicate the control is static text // 13. (Title). Unicode null terminated string with the text // 14. 0x0000. 0 extra bytes of data for this control ////////////////////////////////////////////////////////////////////////// int nTitleLen = (int)lstrlen(pszCaption); int nBufferSize = sizeof(DLGTEMPLATE) + (2 * sizeof(WORD)) + // menu and class ((nTitleLen + 1) * sizeof(WCHAR)); // NOTE - font is set in MsgBoxDlgProc nBufferSize = (nBufferSize + 3) & ~3; // adjust size to make first control DWORD aligned // loop to calculate size of buffer we need add size of each control: // sizeof(DLGITEMTEMPLATE) + // sizeof(WORD) + // atom value flag 0xFFFF // sizeof(WORD) + // ordinal value of control's class // sizeof(WORD) + // no. of bytes in creation data array // sizeof title in WCHARs for (i = 0; i < m_dlgTempl.cdit; i++) { int nItemLength = sizeof(DLGITEMTEMPLATE) + 3 * sizeof(WORD); #ifdef _UNICODE int nActualChars = lstrlen(m_pDlgItemArray[i]->m_pszCaption) + 1; #else int nActualChars = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)m_pDlgItemArray[i].m_pszCaption, -1, NULL, 0); #endif if(nActualChars <= 0) break; nItemLength += nActualChars * sizeof(WCHAR); if (i != m_dlgTempl.cdit - 1) // the last control does not need extra bytes { nItemLength = (nItemLength + 3) & ~3; // take into account gap so next control is DWORD aligned } nBufferSize += nItemLength; } HLOCAL hLocal = LocalAlloc(LHND, nBufferSize); if (hLocal == NULL) { return IDCANCEL; } BYTE* pBuffer = (BYTE*)LocalLock(hLocal); if (pBuffer == NULL) { LocalFree(hLocal); return IDCANCEL; } BYTE* pdest = pBuffer; // transfer DLGTEMPLATE structure to the buffer memcpy(pdest, &m_dlgTempl, sizeof(DLGTEMPLATE)); pdest += sizeof(DLGTEMPLATE); *(WORD*)pdest = 0; // no menu pdest += sizeof(WORD); *(WORD*)pdest = 0; // use default window class pdest += sizeof(WORD); // transfer title WCHAR pchCaption[CAPTION_TEXT_MAX_LEN+80] = {0, }; nTitleLen = min(nTitleLen,CAPTION_TEXT_MAX_LEN); memset(pchCaption, 0, nTitleLen*sizeof(WCHAR)); #ifdef _UNICODE memcpy(pchCaption, pszCaption, nTitleLen*sizeof(WCHAR)); int nActualChars = nTitleLen + 1; #else int nActualChars = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pszCaption, -1, pchCaption, nTitleLen + 1); #endif if(nActualChars <= 0) return IDCANCEL; memcpy(pdest, pchCaption, nActualChars * sizeof(WCHAR)); pdest += nActualChars * sizeof(WCHAR); // will now transfer the information for each one of the item templates for (i = 0; i < m_dlgTempl.cdit; i++) { pdest = (BYTE*)(((DWORD)pdest + 3) & ~3); // make the pointer DWORD aligned memcpy(pdest, (void *)&m_pDlgItemArray[i].m_dlgItemTemplate, sizeof(DLGITEMTEMPLATE)); pdest += sizeof(DLGITEMTEMPLATE); *(WORD*)pdest = 0xFFFF; // indicating atom value pdest += sizeof(WORD); *(WORD*)pdest = (WORD)m_pDlgItemArray[i].m_controltype; // atom value for the control pdest += sizeof(WORD); // transfer the caption even when it is an empty string int nChars = (int)lstrlen(m_pDlgItemArray[i].m_pszCaption) + 1; WCHAR* pszchText = NULL; int nActualChars = 0; #ifdef _UNICODE pszchText = new TCHAR[nChars*sizeof(TCHAR)+4]; if(pszchText) { memset(pszchText, 0, nChars*sizeof(TCHAR) + 4); memcpy(pszchText, m_pDlgItemArray[i]->m_pszCaption, nChars * sizeof(TCHAR)); } nActualChars = nChars; #else pszchText = new WCHAR[nChars*sizeof(WCHAR)+4]; if(pszchText) { nActualChars = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)m_pDlgItemArray[i].m_pszCaption, -1, pszchText, nChars); } #endif if(nActualChars <= 0) break; if(pszchText) { memcpy(pdest, pszchText, nActualChars * sizeof(WCHAR)); } pdest += nActualChars * sizeof(WCHAR); if(pszchText) { delete [] pszchText ; pszchText = NULL; } *(WORD*)pdest = 0; // How many bytes in data for control pdest += sizeof(WORD); } // for if(pdest - pBuffer > nBufferSize) { return 0; } HINSTANCE hInstance = ::GetModuleHandle(NULL); HWND hDlg = ::CreateDialogIndirectParam(hInstance, (LPCDLGTEMPLATE) pBuffer, m_hWndOwner, (DLGPROC)MsgBoxDlgProc, (LPARAM) pDlgBox); DWORD dwError = ::GetLastError(); if (hDlg) { // disable owner - this is a modal dialog ::EnableWindow(m_hWndOwner, FALSE); MSG msg; memset(&msg, 0, sizeof(msg)); // message loop for dialog while (!pDlgBox->m_bShutdown) { msg.message = 0; if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { break; } if (msg.message == WM_KEYDOWN) { // returns TRUE if Ctrl-C processed if (OnKeyDown(hDlg, msg.wParam, msg.lParam)) continue; } if (!::IsDialogMessage(hDlg, &msg)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } } else if (!pDlgBox->m_bShutdown) { ::WaitMessage(); // suspend thread until new message arrives } } if (msg.message == WM_QUIT) { PostQuitMessage((int)msg.wParam); } // re-enable owner if (::IsWindow(m_hWndOwner)) { ::EnableWindow(m_hWndOwner, TRUE); } ::DestroyWindow(hDlg); hDlg = NULL; } // if (hDlg) LocalUnlock(hLocal); LocalFree(hLocal); if (pDlgBox->m_hIcon) DestroyIcon(pDlgBox->m_hIcon); pDlgBox->m_hIcon = 0; if (pDlgBox->m_hFont) ::DeleteObject(pDlgBox->m_hFont); pDlgBox->m_hFont = NULL; if (pDlgBox->m_hBackgroundBrush) ::DeleteObject(pDlgBox->m_hBackgroundBrush); pDlgBox->m_hBackgroundBrush = 0; ret = MAKELONG(pDlgBox->m_nReturnValue, pDlgBox->m_nReturnValueCheckBox); delete pDlgBox; pDlgBox = NULL; return ret; }
void wxZEdit::EditClass(SerializableField *pFields, const char *className, void *ptr, bool bCreateFolder, bool aHandleParentClass) { if (bCreateFolder) { if ( (className[0] == 'P') && (className[1] == 'S') && (className[2] == 'M') && (className[3] == '_')) AddFolder(className+4); else AddFolder(className); } while (pFields->type != SerializableEnd) { if (pFields->type == SerializableBaseClass) { //printf("%s+ %s \n",getTabDepth(depth),pFields->name); if (aHandleParentClass) EditClass((SerializableField *)pFields->size_fieldsOffset, pFields->name, (void*)((((char*)ptr)+pFields->offset)), /*depth, */false, false); } else { // agregated class? if (pFields->type == SerializableAgregat) { if (pFields->count>1) { /* for (unsigned int i= 0;i<pFields->count;i++) { printf("%s%s[%d]\n",getTabDepth(depth),pFields->name,i); DumpObjectValuesFn((SerializableField *)pFields->size_fieldsOffset, pFields->name, (void*)((((char*)ptr)+pFields->offset+(i*gSerializableClasses[pFields->classID].mClassSize))), depth); } */ } else { /* if (pFields->classID == tcolor::mClassID) { AddColorPicker(pFields->name, (tcolor*)((((char*)ptr)+pFields->offset))); } else { } */ //printf("%s%s\n",getTabDepth(depth),pFields->name); //DumpObjectValuesFn((SerializableField *)pFields->size_fieldsOffset, pFields->name, (void*)((((char*)ptr)+pFields->offset)), depth); } } else { /* if (pFields->count>1) { printf("%s%s[%d] = {",getTabDepth(depth),pFields->name,pFields->count); } else printf("%s%s = ",getTabDepth(depth),pFields->name); */ const char *aFieldName = pFields->name; if (aFieldName[0] == 'm') aFieldName++; for (unsigned int i= 0;i<pFields->count;i++) { char *ptrOfset = (((char*)ptr)+pFields->offset+(i*pFields->size_fieldsOffset)); // base switch (pFields->classID) { case SB_UNDEFINED: /*printf("(undefined type)");*/ break; case SB_I8: { if (pFields->mEnumStr) { AddCombo(aFieldName, wxString(pFields->mEnumStr), (unsigned char*)ptrOfset); } else { AddNumEdit<char>(aFieldName, -128, 127, (char*)ptrOfset, 1); } } break; case SB_BOOL: AddCheckBox(aFieldName, (bool*)ptrOfset); break; case SB_UI8: AddNumEdit<unsigned char>(aFieldName, 0, 255, (unsigned char*)ptrOfset, 1); break; case SB_I16: AddNumEdit<short>(aFieldName, -32768, 32767, (short*)ptrOfset, 1); break; case SB_UI16: AddNumEdit<unsigned short>(aFieldName, 0, 65535, (unsigned short*)ptrOfset, 1); break; case SB_I32: AddNumEdit<long>(aFieldName, -2147483647, 2147483647, (long*)ptrOfset, 1); break; case SB_UI32: { if (pFields->mEnumStr) { // bit field unsigned long aBitNb = 0; wxStringTokenizer tkz(pFields->mEnumStr, wxT("|")); while ( tkz.HasMoreTokens() ) { wxString bitFieldName = tkz.GetNextToken(); if (!bitFieldName.IsEmpty()) { AddCheckBoxBitField(bitFieldName, (unsigned long*)ptrOfset, aBitNb); } aBitNb++; } } else { // normal ui32 AddNumEdit<unsigned long>(aFieldName, 0, 4294967295, (unsigned long*)ptrOfset, 1); } } break; case SB_FLOAT: AddNumEdit<float>(aFieldName, -10000000, 10000000, (float*)ptrOfset, 0.1f); break; case SB_DOUBLE: /*printf("%f",*(double*) ptrOfset);*/ break; case SB_STRING: /*printf("%s",(char*) ptrOfset);*/ if (!_stricmp(aFieldName,"name")) AddTextEdit(aFieldName, (tstring*)ptrOfset, 10); else AddTextEdit(aFieldName, (tstring*)ptrOfset); break; case SB_WSTRING: //printf("%s%s = %d \n",getTabDepth(depth),pFields->name,*(int*) (((char*)ptr)+pFields->offset)); break; } //if ((i!=(pFields->count-1))&&(pFields->count>1)) printf(", "); } /* if (pFields->count>1) printf("}\n"); else printf("\n"); */ } } pFields++; } }
//----------------Real code---------------------- BMailProtocolConfigView::BMailProtocolConfigView(uint32 options_mask) : BView (BRect(0,0,100,20), "protocol_config_view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW), fBodyDownloadConfig(NULL) { BRect rect(5,5,245,25); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // determine font height font_height fontHeight; GetFontHeight(&fontHeight); sItemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13; rect.bottom = rect.top - 2 + sItemHeight; if (options_mask & B_MAIL_PROTOCOL_HAS_HOSTNAME) AddChild(AddTextField(rect, "host", B_TRANSLATE("Mail server:"))); if (options_mask & B_MAIL_PROTOCOL_HAS_USERNAME) AddChild(AddTextField(rect, "user", B_TRANSLATE("Username:"******"pass", B_TRANSLATE("Password:"******"flavor", B_TRANSLATE("Connection type:"))); if (options_mask & B_MAIL_PROTOCOL_HAS_AUTH_METHODS) AddChild(AddMenuField(rect, "auth_method", B_TRANSLATE("Login type:"))); // set divider float width = FindWidestLabel(this); for (int32 i = CountChildren();i-- > 0;) { if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i))) text->SetDivider(width + 6); } if (options_mask & B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER) { AddChild(AddCheckBox(rect, "leave_mail_on_server", B_TRANSLATE("Leave mail on server"), new BMessage('lmos'))); BCheckBox* box = AddCheckBox(rect, "delete_remote_when_local", B_TRANSLATE("Remove mail from server when deleted")); box->SetEnabled(false); AddChild(box); } if (options_mask & B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD) { fBodyDownloadConfig = new BodyDownloadConfig(); fBodyDownloadConfig->MoveBy(0, rect.bottom + 5); AddChild(fBodyDownloadConfig); } // resize views float height; GetPreferredSize(&width,&height); ResizeTo(width,height); for (int32 i = CountChildren();i-- > 0;) { // this doesn't work with BTextControl, does anyone know why? -- axeld. if (BView *view = ChildAt(i)) view->ResizeTo(width - 10,view->Bounds().Height()); } }
dskHostGame::dskHostGame(const ServerType serverType) : Desktop(LOADER.GetImageN("setup015", 0)), hasCountdown_(false), serverType(serverType), wasActivated(false) { if(!GAMECLIENT.GetLuaFilePath().empty()) { lua.reset(new LuaInterfaceSettings()); if(!lua->LoadScript(GAMECLIENT.GetLuaFilePath())) { WINDOWMANAGER.Show(new iwMsgbox(_("Error"), _("Lua script was found but failed to load. Map might not work as expected!"), this, MSB_OK, MSB_EXCLAMATIONRED, 1)); lua.reset(); } else if(!lua->EventSettingsInit(serverType == ServerType::LOCAL, GAMECLIENT.IsSavegame())) { RTTR_Assert(GAMECLIENT.IsHost()); // This should be done first for the host so others won't even see the script LOG.lprintf("Lua was disabled by the script itself\n"); lua.reset(); // Double check... if(GAMECLIENT.IsHost()) GAMESERVER.RemoveLuaScript(); } } const bool readonlySettings = !GAMECLIENT.IsHost() || GAMECLIENT.IsSavegame() || (lua && !lua->IsChangeAllowed("general")); allowAddonChange = GAMECLIENT.IsHost() && !GAMECLIENT.IsSavegame() && (!lua || lua->IsChangeAllowed("addonsAll") || lua->IsChangeAllowed("addonsSome")); // Kartenname AddText(0, 400, 5, GAMECLIENT.GetGameName(), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, LargeFont); // "Spielername" AddText(10, 95, 40, _("Player Name"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); // "Einstufung" AddText(11, 205, 40, _("Classification"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); // "Volk" AddText(12, 285, 40, _("Race"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); // "Farbe" AddText(13, 355, 40, _("Color"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); // "Team" AddText(14, 405, 40, _("Team"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); if (!IsSinglePlayer()) { // "Bereit" AddText(15, 465, 40, _("Ready?"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); // "Ping" AddText(16, 515, 40, _("Ping"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); } // "Swap" if(GAMECLIENT.IsHost() && !GAMECLIENT.IsSavegame()) AddText(24, 10, 40, _("Swap"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); // "Verschieben" (nur bei Savegames!) if(GAMECLIENT.IsSavegame()) AddText(17, 645, 40, _("Past player"), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); if (!IsSinglePlayer()) { // Chatfenster AddChatCtrl(1, 20, 320, 360, 218, TC_GREY, NormalFont); // Edit für Chatfenster AddEdit(4, 20, 540, 360, 22, TC_GREY, NormalFont); } // "Spiel starten" AddTextButton(2, 600, 560, 180, 22, TC_GREEN2, (GAMECLIENT.IsHost() ? _("Start game") : _("Ready")), NormalFont); // "Zurück" AddTextButton(3, 400, 560, 180, 22, TC_RED1, _("Return"), NormalFont); // "Teams sperren" AddCheckBox(20, 400, 460, 180, 26, TC_GREY, _("Lock teams:"), NormalFont, readonlySettings); // "Gemeinsame Team-Sicht" AddCheckBox(19, 600, 460, 180, 26, TC_GREY, _("Shared team view"), NormalFont, readonlySettings); // "Random Start Locations" AddCheckBox(23, 600, 430, 180, 26, TC_GREY, _("Random start locations"), NormalFont, readonlySettings); // "Enhancements" AddText(21, 400, 499, _("Addons:"), COLOR_YELLOW, 0, NormalFont); AddTextButton(22, 600, 495, 180, 22, TC_GREEN2, allowAddonChange ? _("Change Settings...") : _("View Settings..."), NormalFont); ctrlComboBox* combo; // umgedrehte Reihenfolge, damit die Listen nicht dahinter sind // "Aufklärung" AddText(30, 400, 405, _("Exploration:"), COLOR_YELLOW, 0, NormalFont); combo = AddComboBox(40, 600, 400, 180, 20, TC_GREY, NormalFont, 100, readonlySettings); combo->AddString(_("Off (all visible)")); combo->AddString(_("Classic (Settlers 2)")); combo->AddString(_("Fog of War")); combo->AddString(_("FoW - all explored")); // "Waren zu Beginn" AddText(31, 400, 375, _("Goods at start:"), COLOR_YELLOW, 0, NormalFont); combo = AddComboBox(41, 600, 370, 180, 20, TC_GREY, NormalFont, 100, readonlySettings); combo->AddString(_("Very Low")); combo->AddString(_("Low")); combo->AddString(_("Normal")); combo->AddString(_("A lot")); // "Spielziel" AddText(32, 400, 345, _("Goals:"), COLOR_YELLOW, 0, NormalFont); combo = AddComboBox(42, 600, 340, 180, 20, TC_GREY, NormalFont, 100, readonlySettings); combo->AddString(_("None")); // Kein Spielziel combo->AddString(_("Conquer 3/4 of map")); // Besitz 3/4 des Landes combo->AddString(_("Total domination")); // Alleinherrschaft // Lobby game? if(LOBBYCLIENT.LoggedIn()) { // Then add tournament modes as possible "objectives" for(unsigned i = 0; i < TOURNAMENT_MODES_COUNT; ++i) { char str[512]; sprintf (str, _("Tournament: %u minutes"), TOURNAMENT_MODES_DURATION[i]); combo->AddString(str); } } // "Geschwindigkeit" AddText(33, 400, 315, _("Speed:"), COLOR_YELLOW, 0, NormalFont); combo = AddComboBox(43, 600, 310, 180, 20, TC_GREY, NormalFont, 100, !GAMECLIENT.IsHost()); combo->AddString(_("Very slow")); // Sehr Langsam combo->AddString(_("Slow")); // Langsam combo->AddString(_("Normal")); // Normal combo->AddString(_("Fast")); // Schnell combo->AddString(_("Very fast")); // Sehr Schnell // Karte laden, um Kartenvorschau anzuzeigen if(GAMECLIENT.GetMapType() == MAPTYPE_OLDMAP) { // Map laden libsiedler2::ArchivInfo mapArchiv; // Karteninformationen laden if(libsiedler2::loader::LoadMAP(GAMECLIENT.GetMapPath(), mapArchiv) == 0) { glArchivItem_Map* map = static_cast<glArchivItem_Map*>(mapArchiv.get(0)); ctrlPreviewMinimap* preview = AddPreviewMinimap(70, 560, 40, 220, 220, map); // Titel der Karte, Y-Position relativ je nach Höhe der Minimap festlegen, daher nochmals danach // verschieben, da diese Position sonst skaliert wird! ctrlText* text = AddText(71, 670, 0, _("Map: ") + GAMECLIENT.GetMapTitle(), COLOR_YELLOW, glArchivItem_Font::DF_CENTER, NormalFont); text->Move(text->GetX(false), preview->GetY(false) + preview->GetBottom() + 10); } } if (IsSinglePlayer() && !GAMECLIENT.IsSavegame()) { // Setze initial auf KI for (unsigned char i = 0; i < GAMECLIENT.GetPlayerCount(); i++) { if (!GAMECLIENT.GetPlayer(i).is_host) GAMESERVER.TogglePlayerState(i); } } // Alle Spielercontrols erstellen for(unsigned char i = GAMECLIENT.GetPlayerCount(); i; --i) UpdatePlayerRow(i - 1); //swap buttons erstellen if(GAMECLIENT.IsHost() && !GAMECLIENT.IsSavegame() && (!lua || lua->IsChangeAllowed("swapping"))) { for(unsigned char i = GAMECLIENT.GetPlayerCount(); i; --i) AddTextButton(80 + i, 5, 80 + (i - 1) * 30, 10, 22, TC_RED1, _("-"), NormalFont);; } // GGS aktualisieren, zum ersten Mal GAMECLIENT.LoadGGS(); this->CI_GGSChanged(GAMECLIENT.GetGGS()); LOBBYCLIENT.SetInterface(this); if(serverType == ServerType::LOBBY && LOBBYCLIENT.LoggedIn()) { LOBBYCLIENT.SendServerJoinRequest(); LOBBYCLIENT.SendRankingInfoRequest(GAMECLIENT.GetPlayer(GAMECLIENT.GetPlayerID()).name); for(unsigned char i = 0; i < GAMECLIENT.GetPlayerCount(); ++i) { GameClientPlayer& player = GAMECLIENT.GetPlayer(i); if(player.ps == PS_OCCUPIED) LOBBYCLIENT.SendRankingInfoRequest(player.name); } } GAMECLIENT.SetInterface(this); }
void LayoutStream::ActiveItemChanged(const QModelIndex& index) { Clear(); const QAbstractItemModel* sender = ((QItemSelectionModel*)QObject::sender())->model(); if (sender->data(index, DffModel::UserRole_Type) != DffModel::IDX_COMMAND) return; current_index = index; dff_model = (QAbstractItemModel*)sender; // TODO: not const-correct... u32 cmd_start = sender->data(index, DffModel::UserRole_CmdStart).toUInt(); cur_fifo_data.clear(); cur_fifo_data.append(sender->data(index, DffModel::UserRole_FifoData).toByteArray()); // TODO: Only retrieve this on dataChanged()... u8* fifo_data = (u8*)cur_fifo_data.data(); if (fifo_data[cmd_start] == GX_LOAD_BP_REG) { u32& cmddata = (*(u32*)&fifo_data[cmd_start+1]); edit_offset = cmd_start+1; edit_size = sizeof(u32); #define GET(type, name) type& name = *(type*)&cmddata if (fifo_data[cmd_start+1] == BPMEM_GENMODE) // 0x00 { GET(GenMode, mode); AddLabel(tr("Gen mode")).endl(); AddLabel(tr("numtexgens: ")).AddSpinBox(mode.numtexgens).endl(); AddLabel(tr("numcolchans: ")).AddSpinBox(mode.numcolchans).endl(); AddCheckBox(mode.ms_en, tr("Enable multisampling")).endl(); AddLabel(tr("numtexstages: ")).AddSpinBox(mode.numtexstages).endl(); AddLabel(tr("Culling: ")).AddComboBox(mode.cullmode, {tr("Disabled"), tr("Cull front facing"), tr("Cull back facing"), tr("Cull everything") }).endl(); AddLabel(tr("numindstages: ")).AddSpinBox(mode.numindstages).endl(); AddCheckBox(mode.zfreeze, tr("Enable zfreeze")).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_SCISSORTL) // 0x20 { GET(X12Y12, coord); AddLabel(tr("Scissor rectangle")).endl(); AddLabel(tr("Left coordinate:")).AddSpinBox(coord.x).endl(); AddLabel(tr("Top coordinate:")).AddSpinBox(coord.y).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_SCISSORBR) // 0x21 { GET(X12Y12, coord); AddLabel(tr("Scissor rectangle")).endl(); AddLabel(tr("Right coordinate:")).AddSpinBox(coord.x).endl(); AddLabel(tr("Bottom coordinate:")).AddSpinBox(coord.y).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_ZMODE) // 0x40 { ZMode& zmode = *(ZMode*)&cmddata; AddLabel(tr("BPMEM_ZMODE")).endl(); AddCheckBox(zmode.testenable, tr("Enable depth testing")).endl(); AddLabel(tr("Depth test function: ")).AddComboBox(zmode.func, {tr("Never"), tr("Less"), tr("Equal"), tr("Less or equal"), tr("Greater"), tr("Not equal"), tr("Greater or equal"), tr("Always")}).endl(); AddCheckBox(zmode.updateenable, tr("Enable depth writing")).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_BLENDMODE) // 0x41 { BlendMode& mode = *(BlendMode*)&cmddata; QStringList dstfactors = { tr("Zero"), tr("One"), tr("SRCCOL"), tr("1-SRCCOL"), tr("SRCALP"), tr("1-SRCALP"), tr("DSTALP"), tr("1-DSTALP") }; QStringList srcfactors = { tr("Zero"), tr("One"), tr("DSTCOL"), tr("1-DSTCOL"), tr("SRCALP"), tr("1-SRCALP"), tr("DSTALP"), tr("1-DSTALP") }; QStringList logicmodes = { "0", "s & d", "s & ~d", "s", "~s & d", "d", "s ^ d", "s | d", "~(s | d)", "~(s ^ d)", "~d", "s | ~d", "~s", "~s | d", "~(s & d)", "1" }; AddLabel(tr("BPMEM_BLENDMODE")).endl(); AddCheckBox(mode.blendenable, tr("Enable blending")).endl(); AddComboBox(mode.dstfactor, dstfactors).endl(); AddComboBox(mode.srcfactor, srcfactors).endl(); AddCheckBox(mode.subtract, tr("Subtract")).endl(); AddCheckBox(mode.logicopenable, tr("Enable logical operations")).endl(); AddLabel(tr("Logic operation: ")).AddComboBox(mode.logicmode, logicmodes).endl(); AddCheckBox(mode.colorupdate, tr("Enable color writing")).endl(); AddCheckBox(mode.alphaupdate, tr("Enable alpha writing")).endl(); AddCheckBox(mode.dither, tr("Enable dithering")).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_ZCOMPARE) // 0x43 { GET(PE_CONTROL, ctrl); AddLabel(tr("Pixel Engine control")).endl(); AddLabel(tr("EFB pixel format: ")).AddComboBox(ctrl.pixel_format, {"RGB8 Z24", "RGBA6 Z24", "RGB565 Z16", "Z24", "Y8", "U8", "V8", "YUV420"}).endl(); AddLabel(tr("EFB depth format: ")).AddComboBox(ctrl.zformat, {tr("Linear"), tr("Near"), tr("Mid"), tr("Far"), tr("Inverse near"), tr("Inverse mid"), tr("Inverse far")}).endl(); AddCheckBox(ctrl.early_ztest, tr("Early depth test")).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_TRIGGER_EFB_COPY) // 0x52 { UPE_Copy& copy = *(UPE_Copy*)&cmddata; AddLabel(tr("BPMEM_TRIGGER_EFB_COPY")).endl(); AddLabel(tr("Clamping: ")).AddCheckBox(copy.clamp0, tr("Top")).AddCheckBox(copy.clamp1, tr("Bottom")).endl(); AddLabel(tr("Convert from RGB to YUV: ")).AddCheckBox(copy.yuv).endl(); AddLabel(tr("Target pixel format: ")).AddComboBox(copy.target_pixel_format, {"Z4/I4/R4", "Z8/I8/R8", "IA4/RA4", "Z16/IA8/RA8", "RGB565", "RGB5A3", "Z24X8/RGBA8", "A8", "Z8/I8/R8", "Z8M/G8", "Z8L/B8"", Z16Rev/RG8", "Z16L/GB8", "", "", "" }).endl(); AddLabel(tr("Gamma correction: ")).AddComboBox(copy.gamma, {"1.0","1.7","2.2","Inv." }).endl(); AddLabel(tr("Downscale: ")).AddCheckBox(copy.half_scale).endl(); AddLabel(tr("Vertical scaling: ")).AddCheckBox(copy.scale_invert).endl(); AddLabel(tr("Clear: ")).AddCheckBox(copy.clear).endl(); AddLabel(tr("Copy to XFB: ")).AddCheckBox(copy.frame_to_field).endl(); AddLabel(tr("Copy as intensity: ")).AddCheckBox(copy.intensity_fmt).endl(); AddLabel(tr("Automatic color conversion: ")).AddCheckBox(copy.auto_conv).endl(); } else if (fifo_data[cmd_start+1] >= BPMEM_TEV_COLOR_ENV && fifo_data[cmd_start+1] <= BPMEM_TEV_ALPHA_ENV + 2*15) // 0xC0 - 0xDF { int stage = (fifo_data[cmd_start+1] - BPMEM_TEV_COLOR_ENV) / 2; QStringList bias_values = { tr("0"), tr("+0.5"), tr("-0.5"), tr("Use compare function") }; QStringList shift_values = { "1.0", "2.0", "4.0", "0.5" }; QStringList outputs = { "PREV", "REG0", "REG1", "REG2"}; QStringList operations = { tr("Add"), tr("Subtract")}; QStringList compare_functions = {"Greater", "Equal"}; if ((fifo_data[cmd_start+1] & 1) == 0) { GET(TevStageCombiner::ColorCombiner, comb); QStringList inputs = { tr("PREV color"), tr("PREV alpha"), tr("REG0 color"), tr("REG0 alpha"), tr("REG1 color"), tr("REG1 alpha"), tr("REG2 color"), tr("REG2 alpha"), tr("Texture color"), tr("Texture alpha"), tr("Rasterized color"), tr("Rasterized alpha"), tr("1"), tr("0.5"), tr("Konst color"), tr("0") }; AddLabel(tr("Color combiner for Tev stage %1").arg(stage)).endl(); AddLabel(tr("Input A: ")).AddComboBox(comb.a, inputs).endl(); AddLabel(tr("Input B: ")).AddComboBox(comb.b, inputs).endl(); AddLabel(tr("Input C: ")).AddComboBox(comb.c, inputs).endl(); AddLabel(tr("Input D: ")).AddComboBox(comb.d, inputs).endl(); AddLabel(tr("Bias: ")).AddComboBox(comb.bias, bias_values).endl(); AddLabel(tr("Operation: ")).AddComboBox(comb.op, operations).endl(); AddCheckBox(comb.clamp, tr("Clamp")).endl(); AddLabel(tr("Scale: ")).AddComboBox(comb.shift, shift_values).endl(); AddLabel(tr("Destination: ")).AddComboBox(comb.dest, outputs).endl(); // TODO: Changing these does not update the upper ones!! AddLabel(tr("Compare operation: ")).AddComboBox(comb.op, compare_functions).endl(); AddLabel(tr("Compared components: ")).AddComboBox(comb.shift, {"R", "GR", "BGR", "RGB per-channel"}).endl(); } else { GET(TevStageCombiner::AlphaCombiner, comb); QStringList inputs = { tr("PREV"), tr("REG0"), tr("REG1"), tr("REG2"), tr("Texture"), tr("Rasterizer"), tr("Konst"), tr("0") }; AddLabel(tr("Alpha combiner for Tev stage %1").arg(stage)).endl(); AddLabel(tr("Input A: ")).AddComboBox(comb.a, inputs).endl(); AddLabel(tr("Input B: ")).AddComboBox(comb.b, inputs).endl(); AddLabel(tr("Input C: ")).AddComboBox(comb.c, inputs).endl(); AddLabel(tr("Input D: ")).AddComboBox(comb.d, inputs).endl(); AddLabel(tr("Bias: ")).AddComboBox(comb.bias, bias_values).endl(); AddLabel(tr("Operation: ")).AddComboBox(comb.op, operations).endl(); AddCheckBox(comb.clamp, tr("Clamp")).endl(); AddLabel(tr("Scale: ")).AddComboBox(comb.shift, shift_values).endl(); AddLabel(tr("Destination: ")).AddComboBox(comb.dest, outputs).endl(); // TODO: Changing these does not update the upper ones!! AddLabel(tr("Compare operation: ")).AddComboBox(comb.op, compare_functions).endl(); AddLabel(tr("Compared components: ")).AddComboBox(comb.shift, {"R", "GR", "BGR", "A"}).endl(); AddLabel(tr("Rasterized input swap: ")).AddSpinBox(comb.rswap).endl(); AddLabel(tr("Texture input swap: ")).AddSpinBox(comb.tswap).endl(); } } else if (fifo_data[cmd_start+1] == BPMEM_FOGRANGE) // 0xE8 { GET(FogRangeParams::RangeBase, range); AddLabel(tr("Fog range adjustment")).endl(); AddCheckBox(range.Enabled, tr("Enable")).endl(); AddLabel(tr("Center: ")).AddSpinBox(range.Center).endl(); } else if (fifo_data[cmd_start+1] >= BPMEM_FOGRANGE + 1 && fifo_data[cmd_start+1] <= BPMEM_FOGRANGE + 5) // 0xE9 - 0xED { GET(FogRangeKElement, range); AddLabel(tr("Fog range adjustment factor group %1").arg(fifo_data[cmd_start+1]-BPMEM_FOGRANGE)).endl(); AddLabel(tr("Factor HI: ")).AddSpinBox(range.HI).endl(); AddLabel(tr("Factor LO: ")).AddSpinBox(range.LO).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_FOGPARAM0) // 0xEE { GET(FogParam0, fog); AddLabel(tr("Fog parameter A")).endl(); AddLabel(tr("Mantissa: ")).AddSpinBox(fog.mantissa).endl(); AddLabel(tr("Exponent: ")).AddSpinBox(fog.exponent).endl(); AddLabel(tr("Sign: ")).AddComboBox(fog.sign, {tr("Positive"), tr("Negative")}).endl(); // TODO: _additionally_ add an input field for directly entering the floating point value! } else if (fifo_data[cmd_start+1] == BPMEM_FOGBMAGNITUDE) // 0xEF { AddLabel(tr("Fog parameter B")).endl(); // TODO! } else if (fifo_data[cmd_start+1] == BPMEM_FOGBEXPONENT) // 0xF0 { AddLabel(tr("Fog parameter B")).endl(); // TODO! } else if (fifo_data[cmd_start+1] == BPMEM_FOGPARAM3) // 0xF1 { GET(FogParam3, fog); AddLabel(tr("Fog configuration and fog parameter C")).endl(); AddLabel(tr("Mantissa: ")).AddSpinBox(fog.c_mant).endl(); AddLabel(tr("Exponent: ")).AddSpinBox(fog.c_exp).endl(); AddLabel(tr("Sign: ")).AddComboBox(fog.c_sign, {tr("Positive"), tr("Negative")}).endl(); AddLabel(tr("Projection mode: ")).AddComboBox(fog.c_sign, {tr("Perspective"), tr("Orthographic")}).endl(); AddLabel(tr("Fog mode: ")).AddComboBox(fog.c_sign, {tr("Disabled"), tr("Unknown"), tr("Linear"), tr("Unknown"), tr("Exponential"), tr("Exponential squared"), tr("Inverse exponential"), tr("Inverse exponential squared")}).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_FOGCOLOR) // 0xF2 { GET(FogParams::FogColor, color); AddLabel(tr("Fog color")).endl(); AddLabel(tr("Red:")).AddSpinBox(color.r).endl(); AddLabel(tr("Green:")).AddSpinBox(color.g).endl(); AddLabel(tr("Blue:")).AddSpinBox(color.b).endl(); } else if (fifo_data[cmd_start+1] == BPMEM_ALPHACOMPARE) // 0xF3 { GET(AlphaTest, test); QStringList comp_funcs = { tr("Never"), tr("Less"), tr("Equal"), tr("Less or equal"), tr("Greater"), tr("Not equal"), tr("Greater or equal"), tr("Always"), }; QStringList alpha_ops = { tr("and"), tr("or"), tr("xor"), tr("equal"), }; AddLabel(tr("Alpha test")).endl(); AddLabel(tr("First reference value: ")).AddSpinBox(test.ref0).endl(); AddLabel(tr("First comparison function: ")).AddComboBox(test.comp0, comp_funcs).endl(); AddLabel(tr("Second reference value: ")).AddSpinBox(test.ref1).endl(); AddLabel(tr("Second comparison function: ")).AddComboBox(test.comp1, comp_funcs).endl(); AddLabel(tr("Combining function: ")).AddComboBox(test.logic, alpha_ops).endl(); } } }