int createWindowWidthheightoriginXyattrlength(int w,int h,int x,int y, char * list, int listLength) { int index; long windowClass,windowAttributes; WindowPtr window; windowDescriptorBlock *windowBlock; if (listLength != 8) return -1; memmove(&windowClass, list, 4); memmove(&windowAttributes, list+4, 4); window = SetUpWindow(y,x,y+h,x+w,windowClass,windowAttributes); if (window == 0) return -1; windowBlock = AddWindowBlock(); windowBlock->handle = (wHandleType) window; index = windowBlock->windowIndex; windowBlock->isInvisible = !MacIsWindowVisible(window); SetUpCarbonEventForWindowIndex(index); QDBeginCGContext(GetWindowPort(windowBlock->handle),&windowBlock->context); // CreateCGContextForPort(GetWindowPort(windowBlock->handle),&windowBlock->context); windowBlock->width = w; windowBlock->height = h; sqShowWindow(index); return index; }
Window::Window(unsigned int widthInit, unsigned int heightInit, std::string title) : width{widthInit}, height{heightInit} { InitializeSDL(); InitializeIMG(); InitializeMixer(); SetUpWindow(width, height, title); }
static void SetWindow(SqueakPlugin *plugin, Window window, int width, int height) { DPRINT("NP: SetWindow(0x%X, %i@%i)\n", window, width, height); if (plugin->nswindow == window) { XResizeWindow(plugin->display, plugin->nswindow, width, height); } else { /* New window */ plugin->nswindow= window; SetUpWindow(plugin); if (plugin->sqwindow) { DPRINT("NP: Reparenting to plugin window 0x%X\n", plugin->nswindow); XReparentWindow(plugin->display, plugin->sqwindow, plugin->nswindow, 0, 0); XMapWindow(plugin->display, plugin->sqwindow); /* notify Squeak */ SendInt(plugin, CMD_BROWSER_WINDOW); SendInt(plugin, plugin->nswindow); } } if (plugin->sqwindow) XResizeWindow(plugin->display, plugin->sqwindow, width, height); }
int Scope::Initialize() { if (SetUpRift() < 0) { MessageBoxW(m_hwnd, L"Error setting up the Rift.", L"Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); return -1; } if (GetRiftDisplayInfo() < 0) { MessageBoxW(m_hwnd, L"Error getting Rift display info.", L"Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); return -1; } ResizeSource(); if (SetUpWindow() < 0) { MessageBoxW(m_hwnd, L"Windows error.", L"Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); return -1; } AllocateWindowsResources(); if (SetUpTimers() < 0) { MessageBoxW(m_hwnd, L"Windows timer error.", L"Error", MB_OK | MB_ICONERROR | MB_SYSTEMMODAL); return -1; } return 0; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { srand((unsigned int)GetTickCount()); // load up settings if(!LoadSettings()) { Log("Failed to load settings"); getchar(); return 0; } if(settings.iConsole) SetUpConsole(); else { SetUpWindow(hInstance); Sleep(500); // wait a bit for the dialog to create } // RCON mode if(settings.runMode == RUNMODE_RCON) { if(RCONReceiveLoop()) { if(flLog != NULL) { fclose(flLog); flLog = NULL; } return 0; } } // set up networking pRakClient = RakNetworkFactory::GetRakClientInterface(); if(pRakClient == NULL) return 0; pRakClient->SetMTUSize(576); resetPools(1, 0); RegisterRPCs(pRakClient); SYSTEMTIME time; GetLocalTime(&time); if(settings.iConsole) { Log(" "); Log("* ===================================================== *"); Log(" RakSAMP " RAKSAMP_VERSION " initialized on %02d/%02d/%02d %02d:%02d:%02d", time.wDay, time.wMonth, time.wYear, time.wHour, time.wMinute, time.wSecond); Log(" Authors: " AUTHOR ""); Log("* ===================================================== *"); Log(" "); } char szInfo[400]; char szLastInfo[400]; int iLastMoney = iMoney; int iLastDrunkLevel = iDrunkLevel; int iLastStatsUpdate = GetTickCount(); while(1) { UpdateNetwork(pRakClient); if(settings.bSpam) sampSpam(); if (settings.bFakeKill) sampFakeKill(); if (settings.bLag) sampLag(); if (settings.bJoinFlood) sampJoinFlood(); if (settings.bChatFlood) sampChatFlood(); if (settings.bClassFlood) sampClassFlood(); processPulsator(); processBulletFlood(); if (!iConnectionRequested) { if(!iGettingNewName) sampConnect(settings.server.szAddr, settings.server.iPort, settings.server.szNickname, settings.server.szPassword, pRakClient); else sampConnect(settings.server.szAddr, settings.server.iPort, g_szNickName, settings.server.szPassword, pRakClient); iConnectionRequested = 1; } if (iAreWeConnected && iGameInited) { static DWORD dwLastInfoUpdate = GetTickCount(); if(dwLastInfoUpdate && dwLastInfoUpdate < (GetTickCount() - 1000)) { char szHealthText[16], szArmourText[16]; if(settings.fPlayerHealth > 200.0f) sprintf_s(szHealthText, sizeof(szHealthText), "N/A"); else sprintf_s(szHealthText, sizeof(szHealthText), "%.2f", settings.fPlayerHealth); if(settings.fPlayerArmour > 200.0f) sprintf_s(szArmourText, sizeof(szArmourText), "N/A"); else sprintf_s(szArmourText, sizeof(szArmourText), "%.2f", settings.fPlayerArmour); sprintf_s(szInfo, 400, "Hostname: %s Players: %d Ping: %d Authors: %s\nHealth: %s Armour: %s Skin: %d X: %.4f Y: %.4f Z: %.4f Rotation: %.4f", g_szHostName, getPlayerCount(), playerInfo[g_myPlayerID].dwPing, AUTHOR, szHealthText, szArmourText, iLocalPlayerSkin, settings.fNormalModePos[0], settings.fNormalModePos[1], settings.fNormalModePos[2], settings.fNormalModeRot); if(strcmp(szInfo, szLastInfo) != 0) { SetWindowText(texthwnd, szInfo); sprintf_s(szLastInfo, szInfo); } } if (settings.iUpdateStats) { if((GetTickCount() - iLastStatsUpdate >= 1000) || iMoney != iLastMoney || iDrunkLevel != iLastDrunkLevel) { RakNet::BitStream bsSend; bsSend.Write((BYTE)ID_STATS_UPDATE); iDrunkLevel -= (rand() % settings.iMaxFPS + settings.iMinFPS); if(iDrunkLevel < 0) iDrunkLevel = 0; bsSend.Write(iMoney); bsSend.Write(iDrunkLevel); pRakClient->Send(&bsSend, HIGH_PRIORITY, RELIABLE, 0); iLastMoney = iMoney; iLastDrunkLevel = iDrunkLevel; iLastStatsUpdate = GetTickCount(); } } if(settings.runMode == RUNMODE_BARE) goto bare; if(!iSpawned) { if(settings.iManualSpawn != 0) { if(!iNotificationDisplayedBeforeSpawn) { sampRequestClass(settings.iClassID); Log("Please write !spawn into the console when you're ready to spawn."); iNotificationDisplayedBeforeSpawn = 1; } } else { sampRequestClass(settings.iClassID); sampSpawn(); iSpawned = 1; iNotificationDisplayedBeforeSpawn = 1; } } else { if(settings.runMode == RUNMODE_STILL) { // Nothing left to do. :-) } if(settings.runMode == RUNMODE_NORMAL) { if(settings.AutoGotoCP && settings.CurrentCheckpoint.bActive) { settings.fNormalModePos[0] = settings.CurrentCheckpoint.fPosition[0]; settings.fNormalModePos[1] = settings.CurrentCheckpoint.fPosition[1]; settings.fNormalModePos[2] = settings.CurrentCheckpoint.fPosition[2]; } onFootUpdateAtNormalPos(); } // Run autorun commands if(settings.iAutorun) { if(dwAutoRunTick && dwAutoRunTick < (GetTickCount() - 2000)) { static int autorun; if(!autorun) { Log("Loading autorun..."); for(int i = 0; i < MAX_AUTORUN_CMDS; i++) if(settings.autoRunCMDs[i].iExists) RunCommand(settings.autoRunCMDs[i].szCMD, 1); autorun = 1; } } } // Following player mode. if(settings.runMode == RUNMODE_FOLLOWPLAYER) { PLAYERID copyingID = getPlayerIDFromPlayerName(settings.szFollowingPlayerName); if(copyingID != (PLAYERID)-1) onFootUpdateFollow(copyingID); } // Following a player with a vehicle mode. if(settings.runMode == RUNMODE_FOLLOWPLAYERSVEHICLE) { PLAYERID copyingID = getPlayerIDFromPlayerName(settings.szFollowingPlayerName); if(copyingID != (PLAYERID)-1) inCarUpdateFollow(copyingID, (VEHICLEID)settings.iFollowingWithVehicleID); } } } bare:; Sleep(30); } if(flLog != NULL) { fclose(flLog); flLog = NULL; } if(flTextDrawsLog != NULL) { fclose(flTextDrawsLog); flTextDrawsLog = NULL; } return 0; }