示例#1
0
// display photo info
//
void InfoPane::UpdateInfo(PhotoInfoPtr photo, bool force)
{
	if (photo_ == photo && !force)
		return;

	photo_ = photo;

	// Note: ideally ResetText() should be invoked for hidden pane (when photo is null),
	// but that leads to scrolling problems with list ctrl;
	//TODO: replace list ctrl by custom wnd
	if (IsPaneVisible())
		ResetText();
}
示例#2
0
bool LoadPrefs()
{
	if(prefLoaded) // already attempted loading
		return true;

	bool prefFound = false;
	char filepath[4][MAXPATHLEN];
	int numDevices;
	
#ifdef HW_RVL
	numDevices = 5;
	sprintf(filepath[0], "%s", appPath);
	sprintf(filepath[1], "sd:/apps/%s", APPFOLDER);
	sprintf(filepath[2], "usb:/apps/%s", APPFOLDER);
	sprintf(filepath[3], "sd:/%s", APPFOLDER);
	sprintf(filepath[4], "usb:/%s", APPFOLDER);
#else
	numDevices = 2;
	sprintf(filepath[0], "carda:/%s", APPFOLDER);
	sprintf(filepath[1], "cardb:/%s", APPFOLDER);
#endif

	for(int i=0; i<numDevices; i++)
	{
		prefFound = LoadPrefsFromMethod(filepath[i]);
		
		if(prefFound)
			break;
	}

	prefLoaded = true; // attempted to load preferences

	if(prefFound)
		FixInvalidSettings();

	ResetText();
	return prefFound;
}
示例#3
0
/*------------------------------------------------------------------------
 Procedure:     HandleCommand ID:1
 Purpose:       Handles all menu commands.
 Input:
 Output:
 Errors:
--------------------------------------------------------------------------
 Edit History:
    06 Oct  2003 - Chris Watford [email protected]
        - Removed entries that crashed OCaml
        - Removed useless entries
        - Added Save ML and Save Transcript
------------------------------------------------------------------------*/
void HandleCommand(HWND hwnd, WPARAM wParam,LPARAM lParam)
{
        char *fname;
        int r;

        switch(LOWORD(wParam)) {
                case IDM_OPEN:
                        fname = SafeMalloc(512);
                        if (OpenMlFile(fname,512)) {
                                char *buf = SafeMalloc(512);
                                char *p = strrchr(fname,'.');
                                if (p && !stricmp(p,".ml")) {
                                        wsprintf(buf, "#use \"%s\";;", fname);
                                        AddLineToControl(buf);
                                }
                                else if (p && !stricmp(p,".cmo")) {
                                        wsprintf(buf, "#load \"%s\";;", fname);
                                        AddLineToControl(buf);
                                }
                                free(buf);
                        }
                        free(fname);
                        break;
                case IDM_GC:
                        AddLineToControl("Gc.full_major();;");
                        break;
                case IDCTRLC:
                        InterruptOcaml();
                        break;
                case IDM_EDITPASTE:
                        Add_Clipboard_To_Queue();
                        break;
                case IDM_EDITCOPY:
                        CopyToClipboard(hwnd);
                        break;

                // updated to save a transcript
                case IDM_SAVEAS:
                        fname = SafeMalloc(512);
                        if (GetSaveName(fname,512)) {
                                SaveText(fname);
                        }
                        free(fname);
                        break;

                // updated to save an ML file
                case IDM_SAVE:
                        fname = SafeMalloc(512);
                        if (GetSaveMLName(fname,512))
                        {
                                SaveML(fname);
                        }
                        free(fname);
                        break;

                // updated to work with new history system
                case IDM_HISTORY:
                        r = CallDlgProc(HistoryDlgProc,IDD_HISTORY);

                        if (r)
                        {
                                AddLineToControl(GetHistoryLine(r-1));
                        }
                        break;

                case IDM_PRINTSU:
                        // Removed by Chris Watford
                        // seems to die
                        // CallPrintSetup();
                        break;

                case IDM_FONT:
                        CallChangeFont(hwndMain);
                        break;
                case IDM_COLORTEXT:
                        ProgramParams.TextColor = CallChangeColor(ProgramParams.TextColor);
                        ForceRepaint();
                        break;
                case IDM_BACKCOLOR:
                        BackColor = CallChangeColor(BackColor);
                        DeleteObject(BackgroundBrush);
                        BackgroundBrush = CreateSolidBrush(BackColor);
                        ForceRepaint();
                        break;
                case IDM_EDITUNDO:
                        Undo(hwnd);
                        break;

                /* Removed, really not very useful in this IDE
                case IDM_WINDOWTILE:
                        SendMessage(hwndMDIClient,WM_MDITILE,0,0);
                        break;
                case IDM_WINDOWCASCADE:
                        SendMessage(hwndMDIClient,WM_MDICASCADE,0,0);
                        break;
                case IDM_WINDOWICONS:
                        SendMessage(hwndMDIClient,WM_MDIICONARRANGE,0,0);
                        break;
                */

                case IDM_EXIT:
                        PostMessage(hwnd,WM_CLOSE,0,0);
                        break;
                case IDM_ABOUT:
                        CallDlgProc(AboutDlgProc,IDD_ABOUT);
                        break;
                default:
                        if (LOWORD(wParam) >= IDEDITCONTROL && LOWORD(wParam) < IDEDITCONTROL+5) {
                                switch (HIWORD(wParam)) {
                                        case EN_ERRSPACE:
                                                ResetText();
                                                break;
                                }
                        }
                        break;
        }
}
示例#4
0
void InfoPane::OnTogglePreview()
{
	img_preview_ = !img_preview_;
	Resize();
	ResetText();
}
示例#5
0
bool LoadPrefs()
{
	if(prefLoaded) // already attempted loading
		return true;

	bool prefFound = false;
	char filepath[5][MAXPATHLEN];
	int numDevices;
	
#ifdef HW_RVL
	numDevices = 5;
	sprintf(filepath[0], "%s", appPath);
	sprintf(filepath[1], "sd:/apps/%s", APPFOLDER);
	sprintf(filepath[2], "usb:/apps/%s", APPFOLDER);
	sprintf(filepath[3], "sd:/%s", APPFOLDER);
	sprintf(filepath[4], "usb:/%s", APPFOLDER);
#else
	numDevices = 2;
	sprintf(filepath[0], "carda:/%s", APPFOLDER);
	sprintf(filepath[1], "cardb:/%s", APPFOLDER);
#endif

	for(int i=0; i<numDevices; i++)
	{
		prefFound = LoadPrefsFromMethod(filepath[i]);
		
		if(prefFound)
			break;
	}

	prefLoaded = true; // attempted to load preferences

	if(prefFound)
		FixInvalidSettings();
	
	// rename snes9x to snes9xgx
	if(GCSettings.LoadMethod == DEVICE_SD)
	{
		if(ChangeInterface(DEVICE_SD, NOTSILENT) && opendir("sd:/snes9x"))
			rename("sd:/snes9x", "sd:/snes9xgx");
	}
	else if(GCSettings.LoadMethod == DEVICE_USB)
	{
		if(ChangeInterface(DEVICE_USB, NOTSILENT) && opendir("usb:/snes9x"))
			rename("usb:/snes9x", "usb:/snes9xgx");
	}
	else if(GCSettings.LoadMethod == DEVICE_SMB)
	{
		if(ChangeInterface(DEVICE_SMB, NOTSILENT) && opendir("smb:/snes9x"))
			rename("smb:/snes9x", "smb:/snes9xgx");
	}

	// update folder locations
	if(strcmp(GCSettings.LoadFolder, "snes9x/roms") == 0)
		sprintf(GCSettings.LoadFolder, "snes9xgx/roms");
	
	if(strcmp(GCSettings.SaveFolder, "snes9x/saves") == 0)
		sprintf(GCSettings.SaveFolder, "snes9xgx/saves");
	
	if(strcmp(GCSettings.CheatFolder, "snes9x/cheats") == 0)
		sprintf(GCSettings.CheatFolder, "snes9xgx/cheats");
		
	if(strcmp(GCSettings.ScreenshotsFolder, "snes9x/screenshots") == 0)
		sprintf(GCSettings.ScreenshotsFolder, "snes9xgx/screenshots");

	ResetText();
	return prefFound;
}
示例#6
0
/*------------------------------------------------------------------------
Procedure:     MdiChildWndProc ID:1
Purpose:       The edit control is enclosed in a normal MDI window.
This is the window procedure for that window. When it
receives the WM_CREATE message, it will create the
edit control.
Input:
Output:
Errors:
--------------------------------------------------------------------------
Edit History:
	14 Sept 2003 - Chris Watford [email protected]
		- Added edit buffer and statement buffer support to the WM_NEWLINE
		  message.
	15 Sept 2003 - Chris Watford [email protected]
		- Got it adding to the edit buffer
	16 Sept 2003 - Chris Watford [email protected]
		- Proper handling of newline message finished
	21 Sept 2003 - Chris Watford [email protected]
		- Added error detection on return from ocaml interp
	23 Sept 2003 - Chris Watford [email protected]
		- Fixed prompt detection error as pointed out by Patrick Meredith
------------------------------------------------------------------------*/
static LRESULT CALLBACK MdiChildWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
{
	HWND hwndChild;
	RECT rc;
	HDC hDC;

	switch(msg) {
		case WM_CREATE:
			GetClientRect(hwnd,&rc);
			hwndChild= CreateWindow("EDIT",
				NULL,
				WS_CHILD | WS_VISIBLE |
				ES_MULTILINE |
				WS_VSCROLL | WS_HSCROLL |
				ES_AUTOHSCROLL | ES_AUTOVSCROLL,
				0,
				0,
				(rc.right-rc.left),
				(rc.bottom-rc.top),
				hwnd,
				(HMENU) EditControls++,
				hInst,
				NULL);
			SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) hwndChild);
			SendMessage(hwndChild, WM_SETFONT, (WPARAM) ProgramParams.hFont, 0L);
			SendMessage(hwndChild,EM_LIMITTEXT,0xffffffff,0);
			SubClassEditField(hwndChild);
			break;
			// Resize the edit control
		case WM_SIZE:
			hwndChild = (HWND) GetWindowLongPtr(hwnd, DWLP_USER);
			MoveWindow(hwndChild, 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE);
			break;
			// Always set the focus to the edit control.
		case WM_SETFOCUS:
			hwndChild = (HWND) GetWindowLongPtr(hwnd, DWLP_USER);
			SetFocus(hwndChild);
			break;
			// Repainting of the edit control about to happen.
			// Set the text color and the background color
		case WM_CTLCOLOREDIT:
			hDC = (HDC)wparam;
			SetTextColor(hDC,ProgramParams.TextColor);
			SetBkColor(hDC,BackColor);
			return (LRESULT)BackgroundBrush;
			// Take care of erasing the background color to avoid flicker
		case WM_ERASEBKGND:
			GetWindowRect(hwnd,&rc);
			hDC = (HDC)wparam;
			FillRect(hDC,&rc,BackgroundBrush);
			return 1;
			// A carriage return has been pressed. Send the data to the interpreted.
			// This message is posted by the subclassed edit field.
		case WM_COMMAND:
			if (LOWORD(wparam) >= IDEDITCONTROL && LOWORD(wparam) < IDEDITCONTROL+5) {
				switch (HIWORD(wparam)) {
					case EN_ERRSPACE:
					case EN_MAXTEXT:
						ResetText();
						break;
				}
			}
			break;
		case WM_NEWLINE:
			if (busy)
				break;

			hwndChild = (HWND) GetWindowLongPtr(hwnd, DWLP_USER);

			// add what they wrote to the edit buffer
			AppendToEditBuffer(hwndChild);

		/** Modified by Chris Watford 14 Sept 2003, 15 Sept 2003, 16 Sept 2003 **/
			// test if this line has an end or if it needs to be in the Edit Buffer
			if(SendingFullCommand())
			{
				// send the edit buffer to the interpreter
				//SendLastLine(hwndChild);
				SendLastEditBuffer(hwndChild);
				historyEntry = NULL;
			} else {
				AddStringToControl("  ");
			}
		/** End Modifications **/

			break;
			// The timer will call us 4 times a second. Look if the interpreter
			// has written something in its end of the pipe.
		case WM_TIMERTICK:
		/** Modified by Chris Watford 21 Sept 2003 **/
			hwndChild = (HWND) GetWindowLongPtr(hwnd, DWLP_USER);

			if (ReadToLineBuffer())
			{
				int errMsg = 0;
				char *p, *l = lineBuffer;

				// Ok we read something. Display the trimmed version
				while(((*l) == ' ') || ((*l) == '\t') || ((*l) == '\n') || ((*l) == '\r') || ((*l) == '*'))
					l++;

				SendMessage(hwndChild,EM_REPLACESEL,0,(LPARAM)l);

				// fix bug where it won't find prompt
				p = strrchr(l, '\r');
				if((l[0] == '#') || (p != NULL))
				{
					if(p != NULL)
					{
						if(!strcmp(p, "\r\n# "))
						{
							SetLastPrompt(hwndChild);
						}
					// solve the bug Patrick found
					} else if((l[0] == '#') && (l[1] == ' ')) {
						SetLastPrompt(hwndChild);
					}
				}

				// detect syntax errors
				if(strstr(lineBuffer, "Syntax error"))
				{
					errMsg = WM_SYNTAXERROR;
				} else if(strstr(lineBuffer, "Illegal character")) {
					errMsg = WM_ILLEGALCHAR;
				} else if(strstr(lineBuffer, "Unbound value")) {
					errMsg = WM_UNBOUNDVAL;
				}

				// error! error! alert alert!
				if(errMsg > 0)
				{
					int len = strlen(lineBuffer);
					char* err = (char*)SafeMalloc(len+1);
					char *m = err, *n1 = NULL, *n2 = NULL, *nt = NULL;

					// make a copy of the message
					strncpy(err, lineBuffer, len);
					err[len] = '\0';

					// find it
					m = strstr(err, "Characters ");
					if(m == NULL)
						break;

					// got the start char
					n1 = m + strlen("Characters ");
					
					// start looking for the end char
					nt = strstr(n1, "-");
					if(nt == NULL)
						break;
					
					// makes n1 a valid string
					nt[0] = '\0';

					// end char is right after this
					n2 = nt + 1;

					// find the end of n2
					nt = strstr(n2, ":");
					if(nt == NULL)
						break;

					// makes n2 a valid string
					nt[0] = '\0';

					SendMessage(hwndChild, errMsg, (WPARAM)atoi(n1), (LPARAM)atoi(n2));
				}
			}
		/** End Modifications **/

			break;

	}
	return DefMDIChildProc(hwnd, msg, wparam, lparam);
}
示例#7
0
文件: Netcode.cpp 项目: JonnyIrl/FYP
void Netcode::ReceivePacket()
{
	bool quit = false;

	while (!quit)
	{
		sf::Packet packet;
		list<string> messages;
		bool replied = false;

		sf::Socket::Status status = listener.receive(packet, m_ipAddress, m_personalPort);

		//retryCount++;

		switch (status)
		{
		case sf::Socket::Error:

			break;
		case sf::Socket::Done:
			PacketType type;
			sf::Uint32 size;
			//unsigned short port;
			packet >> type;


			//If we get this far then we have got a message from the server so no need to open the packet up and check.
			if (type == INITIAL_CONNECT_DATA)
			{
				SetPlayerAsClient(false);
				break;
			}

			//If we get this far then we have got a message from the server so no need to open the packet up and check.
			if (type == SERVER_REPLY_MSG)
			{
				cout << "Got Server reply message!" << endl;
				m_connected = true;
				m_receivedReply = true;
				break;
			}

			//If we get this far then we have got a message from the server so no need to open the packet up and check.
			if (type == UPDATE_MSG)
			{
				cout << "Update Message" << endl;
				packet >> size;
				cout << "Size = " << size << endl;

				for (sf::Uint32 i = 0; i < size; ++i)
				{
					string item;
					packet >> item;
					messages.push_back(item);
				}

				cout << "Messages size = " << messages.size();
				//Update the chat window with the text.
				UpdateChatWindow(messages);
				cout << "Updated chat window" << endl;
				ResetText();
				cout << "Reset text" << endl;
				m_receivedReply = true;
				break;
			}

			//If we get this far then we have got a message from the server so no need to open the packet up and check.
			if (type == CHEST_MESSAGE)
			{
				cout << "Chest Message" << endl;
				packet >> size;
				cout << "Size = " << size << endl;

				for (sf::Uint32 i = 0; i < size; ++i)
				{
					float xPos;
					packet >> xPos;
					m_Xpositions.push_back(xPos);
				}

				packet >> size;
				cout << "Size = " << size << endl;

				for (sf::Uint32 i = 0; i < size; ++i)
				{
					float yPos;
					packet >> yPos;
					m_Ypositions.push_back(yPos);
				}

				packet >> size;
				cout << "Size = " << size << endl;

				for (sf::Uint32 i = 0; i < size; ++i)
				{
					float loot;
					packet >> loot;
					m_lootType.push_back(loot);
				}

				m_chestUpdate = true;
				cout << "Got Chest Information" << endl;
				break;
			}

			if (type == NEW_PLAYER_CONNECTED)
			{
				string playerID;
				string playerIP;
				bool ready;

				packet >> playerID >> playerIP >> ready;
				cout << "New Player = " << playerID << " IP = " << playerIP << " Ready = " << ready << endl;

				//If the clients doesnt exist then add them..
				if (!clients.CheckIfClientExists(playerIP))
				{
					clients.AddNewClient(playerIP, playerID, clients.Size() + 1, ready);
					cout << "Added new client " << playerIP << " : " << playerID << " Ready = " << ready << endl;
					clients.GetVector().at(clients.FindWhatNumberClientsWhoSentReadyIs(playerIP))->SetReady(ready);
					AddClientData(playerID);
					pm.AddNewPlayer(playerIP, playerID);
				}
				break;
			}