void GamePan::createNextPuzzle() { _answerStr = ""; initWordList(); resetGamePan(); isCheckWin = false; }
void GamePan::doOpen() { GUIBase::doOpen(); isCheckWin=false; _isPlayer = true; addNpc(DBManager::sharedDBManager()->getActor(1)); addPlayer(DBManager::sharedDBManager()->getActor(2)); initWordList(); refreshWorldPad(); showHideConfirmPad(false); _curTime = TIME_OUT; CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanBg); CCLabelBMFont* timerTxt = dynamic_cast<CCLabelBMFont*>(pBaseNode->getChildByTag(kTagGamePanBgTimer)); int timeStr = (int)_curTime; timerTxt->setString(Utils::itos(timeStr).c_str()); changeSide(); }
void CallComplete(PARSE_STATUS_2 ps, LPARAM lParam) { inputlock = false; DebugOut("Complete:\t%d\n", GetTickCount()); switch (ps) { case PARSE2_ERROR: inputlock = true; logMessage(PARSE_ERROR_MESSAGE, strlen(PARSE_ERROR_MESSAGE), true); inputlock = false; break; case PARSE2_EXTERNAL_ERROR: inputlock = true; logMessage(EXTERNAL_ERROR_MESSAGE, strlen(EXTERNAL_ERROR_MESSAGE), true); inputlock = false; break; case PARSE2_INCOMPLETE: Prompt(CONTINUATION_PROMPT); return; default: initWordList(); break; } if (!lParam) { cmdVector.clear(); Prompt(); } DebugOut("Done:\t%d\n", GetTickCount()); }
LRESULT CALLBACK WindowProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { const int borderedge = 0; // 8; const int topspace = 0; static HWND hwndScintilla = 0; HWND hWnd = 0; char *szBuffer = 0; RECT rect; static UINT_PTR tid = 0; switch (message) { case WM_INITDIALOG: case WM_CREATE: exitpending = false; ::GetClientRect(hwndDlg, &rect); { HMENU hMenu = (HMENU)::LoadMenu(ghModule, MAKEINTRESOURCE(IDR_CONSOLEMENU)); if (hMenu != INVALID_HANDLE_VALUE){ ::SetMenu(hwndDlg, hMenu); DWORD dw; if (CRegistryUtils::GetRegDWORD(HKEY_CURRENT_USER, &dw, REGISTRY_KEY, REGISTRY_VALUE_CONSOLE_ON_TOP) && dw) { CheckMenuItem( hMenu, ID_CONSOLE_ALWAYSONTOP , MF_CHECKED ); } } } hwndScintilla = CreateWindowExA(0, "Scintilla", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN, borderedge, borderedge + topspace, rect.right - 2 * borderedge, rect.bottom - 2 * borderedge - topspace, hwndDlg, 0, ghModule, NULL); if (hwndScintilla) { lpfnEditWndProc = (WNDPROC)SetWindowLongPtr(hwndScintilla, GWLP_WNDPROC, (LONG_PTR)SubClassProc); ::SetFocus(hwndScintilla); fn = (sptr_t(__cdecl *)(sptr_t*, int, uptr_t, sptr_t))SendMessage(hwndScintilla, SCI_GETDIRECTFUNCTION, 0, 0); ptr = (sptr_t*)SendMessage(hwndScintilla, SCI_GETDIRECTPOINTER, 0, 0); char buffer[64]; DWORD dw; fn(ptr, SCI_SETCODEPAGE, SC_CP_UTF8, 0); SetConsoleDefaults(); fn(ptr, SCI_SETMARGINWIDTHN, 1, 0); std::list< std::string > loglist; getLogText(loglist); for (std::list< std::string >::iterator iter = loglist.begin(); iter != loglist.end(); iter++) { if (!strncmp(iter->c_str(), DEFAULT_PROMPT, 2) || !strncmp(iter->c_str(), CONTINUATION_PROMPT, 2)) { AppendLog(iter->c_str(), 0, 0); } else AppendLog(iter->c_str(), 1, 0); } Prompt(); //if (!wlInit) initWordList(); tid = ::SetTimer(hwndDlg, TIMERID_FLUSHBUFFER, 1000, TimerProc); } else { DWORD dwErr = ::GetLastError(); char sz[64]; sprintf_s(sz, 64, "FAILED: 0x%x", dwErr); OutputDebugStringA(sz); ::MessageBoxA(0, sz, "ERR", MB_OK); EndDialog(hwndDlg, IDCANCEL); return TRUE; } hWndConsole = hwndDlg; if (rectConsole.right == rectConsole.left) { ::SetWindowPos(hwndDlg, HWND_TOP, 0, 0, 600, 400, SWP_NOZORDER); } else { ::SetWindowPos(hwndDlg, HWND_TOP, rectConsole.left, rectConsole.top, rectConsole.right - rectConsole.left, rectConsole.bottom - rectConsole.top, SWP_NOZORDER); } break; case WM_SIZE: case WM_WINDOWPOSCHANGED: case WM_SIZING: ::GetClientRect(hwndDlg, &rect); ::SetWindowPos(hwndScintilla, HWND_TOP, borderedge, borderedge + topspace, rect.right - 2 * borderedge, rect.bottom - 2 * borderedge - topspace, SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE); if ( message == WM_SIZE ) UpdateConsoleWidth(); break; case WM_ERASEBKGND: break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case SCN_MODIFIED: // what am I trapping this for? // A: was thinking about handling PASTE { // SCNotification *scn = (SCNotification*)lParam; // DebugOut("Modified: 0x%x\n", scn->modificationType); } case SCN_CHARADDED: { SCNotification *scn = (SCNotification*)lParam; // DebugOut("CA: %x\n", scn->ch); // I think because I switched to utf-8 I'm gettings // double notifications if (scn->ch) testAutocomplete(); } break; } break; case WM_SETFOCUS: ::SetFocus(hwndScintilla); break; case WM_APPEND_LOG: AppendLog((const char*)lParam); break; case WM_DESTROY: ::GetWindowRect(hwndDlg, &rectConsole); if (tid) { ::KillTimer(hwndDlg, tid); tid = 0; } hWndConsole = 0; ::PostQuitMessage(0); break; case WM_CALL_COMPLETE: CallComplete((PARSE_STATUS_2)wParam, lParam); break; case WM_COMMAND: switch (LOWORD(wParam)) { case WM_CLEAR_BUFFER: case ID_CONSOLE_CLEARHISTORY: ClearHistory(); break; case ID_CONSOLE_INSTALLPACKAGES: SafeCall(SCC_INSTALLPACKAGES, 0, 0); break; case ID_CONSOLE_HOMEDIRECTORY: BERT_HomeDirectory(); break; case ID_CONSOLE_RELOADSTARTUPFILE: SafeCall(SCC_RELOAD_STARTUP, 0, 0); break; case WM_REBUILD_WORDLISTS: initWordList(); break; case ID_CONSOLE_CONSOLEOPTIONS: ConsoleOptions(hwndDlg); break; case ID_CONSOLE_ALWAYSONTOP: ToggleOnTop(hwndDlg); reopenWindow = true; ::SetFocus(hWndExcel); ShowWindow(hwndDlg, SW_HIDE); ::PostMessage(hwndDlg, WM_DESTROY, 0, 0); break; // this message is used in case the close console command // is called interactively; in that event we will be in the middle // of a COM call and we don't want to break here. wait until the // call is complete. if it's called some other way (such as from // excel, which it should not be), then you can close. case WM_CLOSE_CONSOLE_ASYNC: if (inputlock) { exitpending = true; break; } case ID_CONSOLE_CLOSECONSOLE: case WM_CLOSE_CONSOLE: case IDOK: case IDCANCEL: ::GetWindowRect(hwndDlg, &rectConsole); if (tid) { ::KillTimer(hwndDlg, tid); tid = 0; } EndDialog(hwndDlg, wParam); ::CloseWindow(hwndDlg); hWndConsole = 0; ::PostQuitMessage(0); return TRUE; } break; } return DefWindowProc(hwndDlg, message, wParam, lParam); return FALSE; }