/** ** Begin input. */ static void UiBeginInput() { KeyState = KeyStateInput; Input[0] = '\0'; InputIndex = 0; ClearCosts(); ShowInput(); }
void Event_pagedown(SubWin sw){ DayData head = (DayData)shmat(QueryByNo(600000), NULL, 0); DrawCan(sw, head); ShowInput("600000"); // SDL_Rect f = {0,0,100,100}; // SDL_FillRect(screen, &f, 0x00000); SDL_Flip(screen); }
int main(void) { int n=0,m=0; //n = 행, m = 열 0<n,m<100 char *arr; //행렬의 값을 동적 배열로 표현 scanf("%d %d",&n,&m); arr = (char *)malloc(sizeof(char)*n*m); InsertInput(n, m, arr); ShowInput(n, m, arr); MakeMine(n, m, arr); }
void Chat::Show() { uint now = Time::GetInstance()->ReadSec(); if (now - last_time >= MAXSECONDS){ chat.DeleteLine(); last_time = now; } chat.Draw(XPOS, YPOS, HEIGHT); if(check_input) ShowInput(); }
/** ** Handle keys in input mode. ** ** @param key Key scancode. ** @return True input finished. */ static int InputKey(int key) { char ChatMessage[sizeof(Input) + 40]; int i; char *namestart; char *p; char *q; switch (key) { case SDLK_RETURN: case SDLK_KP_ENTER: // RETURN // Replace ~~ with ~ for (p = q = Input; *p;) { if (*p == '~') { ++p; } *q++ = *p++; } *q = '\0'; #ifdef DEBUG if (Input[0] == '-') { if (!GameObserve && !GamePaused) { CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, Input, -1); CclCommand(Input + 1, false); } } else #endif if (!IsNetworkGame()) { if (!GameObserve && !GamePaused) { if (HandleCheats(Input)) { CommandLog("input", NoUnitP, FlushCommands, -1, -1, NoUnitP, Input, -1); } } } // Check for Replay and ffw x #ifdef DEBUG if (strncmp(Input, "ffw ", 4) == 0) { #else if (strncmp(Input, "ffw ", 4) == 0 && ReplayGameType != ReplayNone) { #endif FastForwardCycle = atoi(&Input[4]); } if (Input[0]) { // Replace ~ with ~~ for (p = Input; *p; ++p) { if (*p == '~') { q = p + strlen(p); q[1] = '\0'; while (q > p) { *q = *(q - 1); --q; } ++p; } } snprintf(ChatMessage, sizeof(ChatMessage), "~%s~<%s>~> %s", PlayerColorNames[ThisPlayer->Index].c_str(), ThisPlayer->Name.c_str(), Input); // FIXME: only to selected players ... NetworkChatMessage(ChatMessage); } // FALL THROUGH case SDLK_ESCAPE: KeyState = KeyStateCommand; UI.StatusLine.Clear(); return 1; case SDLK_BACKSPACE: if (InputIndex) { if (Input[InputIndex - 1] == '~') { Input[--InputIndex] = '\0'; } InputIndex = UTF8GetPrev(Input, InputIndex); if (InputIndex >= 0) { Input[InputIndex] = '\0'; ShowInput(); } } return 1; case SDLK_TAB: namestart = strrchr(Input, ' '); if (namestart) { ++namestart; } else { namestart = Input; } if (!strlen(namestart)) { return 1; } for (i = 0; i < PlayerMax; ++i) { if (Players[i].Type != PlayerPerson) { continue; } if (!strncasecmp(namestart, Players[i].Name.c_str(), strlen(namestart))) { InputIndex += strlen(Players[i].Name.c_str()) - strlen(namestart); strcpy_s(namestart, sizeof(Input) - (namestart - Input), Players[i].Name.c_str()); if (namestart == Input) { InputIndex += 2; strcat_s(namestart, sizeof(Input) - (namestart - Input), ": "); } ShowInput(); } } return 1; default: if (key >= ' ') { gcn::Key k(key); std::string kstr = k.toString(); if (key == '~') { if (InputIndex < (int)sizeof(Input) - 2) { Input[InputIndex++] = key; Input[InputIndex++] = key; Input[InputIndex] = '\0'; ShowInput(); } } else if (InputIndex < (int)(sizeof(Input) - kstr.size())) { for (size_t i = 0; i < kstr.size(); ++i) { Input[InputIndex++] = kstr[i]; } Input[InputIndex] = '\0'; ShowInput(); } return 1; } break; } return 0; } /** ** Save a screenshot. */ static void Screenshot() { CFile fd; char filename[30]; int i; for (i = 1; i <= 99; ++i) { // FIXME: what if we can't write to this directory? snprintf(filename, sizeof(filename), "screen%02d.png", i); if (fd.open(filename, CL_OPEN_READ) == -1) { break; } fd.close(); } SaveScreenshotPNG(filename); }
/** ** Handle keys in command mode. ** ** @param key Key scancode. ** @return True, if key is handles; otherwise false. */ local int CommandKey(int key) { switch( key ) { case '\r': KeyState=KeyStateInput; Input[0]='\0'; InputIndex=0; ShowInput(); return 1; case '^': UnSelectAll(); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if( KeyModifiers&ModifierControl ) { // dirty atoi version :) SetGroup(Selected,NumSelected,key-48); } else { SelectGroup(key-48); } UpdateBottomPanel(); MustRedraw|=RedrawCursor|RedrawMap|RedrawPanels; break; #if 0 IfDebug( case '0': ++ThisPlayer; if( ThisPlayer==&Players[PlayerMax] ) { ThisPlayer=&Players[0]; } MustRedraw=RedrawEverything; break; case '1': --ThisPlayer; if( ThisPlayer<&Players[0] ) { ThisPlayer=&Players[PlayerMax-1]; } MustRedraw=RedrawEverything; break; ); #endif case KeyCodePause: case 'P': // If pause-key didn't work if(GamePaused) { GamePaused=0; SetStatusLine("Game Resumed"); } else { GamePaused=1; SetStatusLine("Game Paused"); } break; case KeyCodeF10: InterfaceState=IfaceStateMenu; GamePaused=1; SetStatusLine("Game Paused"); ProcessMenu(MENU_GAME); break; case '+': VideoSyncSpeed+=10; InitVideoSync(); SetStatusLine("Faster"); break; case '-': VideoSyncSpeed-=10; InitVideoSync(); SetStatusLine("Slower"); break; case 'S': // SMALL s is needed for panel SaveAll(); break; case 'c': if( NumSelected==1 ) { MapCenter(Selected[0]->X,Selected[0]->Y); } break; // TAB toggles minimap. // FIXME: more... case '\t': DebugLevel1("TAB\n"); MinimapWithTerrain^=1; MustRedraw|=RedrawMinimap; break; // FIXME: shift+TAB case 'q': Exit(0); case KeyCodeUp: if( MapY ) { if( KeyModifiers&ModifierControl ) { if( MapY<MapHeight/2 ) { MapY=0; } else { MapY-=MapHeight/2; } } else { --MapY; } MustRedraw|=RedrawMaps|RedrawMinimapCursor; } break; case KeyCodeDown: if( MapY<TheMap.Height-MapHeight ) { if( KeyModifiers&ModifierControl ) { if( MapY<TheMap.Height-MapHeight-MapHeight/2 ) { MapY+=MapHeight/2; } else { MapY=TheMap.Height-MapHeight; } } else { ++MapY; } MustRedraw|=RedrawMaps|RedrawMinimapCursor; } break; case KeyCodeLeft: if( MapX ) { if( KeyModifiers&ModifierControl ) { if( MapX<MapWidth/2 ) { MapX=0; } else { MapX-=MapWidth/2; } } else { --MapX; } MustRedraw|=RedrawMaps|RedrawMinimapCursor; } break; case KeyCodeRight: if( MapX<TheMap.Width-MapWidth ) { if( KeyModifiers&ModifierControl ) { if( MapX<TheMap.Width-MapWidth-MapWidth/2 ) { MapX+=MapWidth/2; } else { MapX=TheMap.Width-MapWidth; } } else { ++MapX; } MustRedraw|=RedrawMaps|RedrawMinimapCursor; } break; default: DebugLevel3("Key %d\n",key); return 0; }