Network code and pc.c are more platform-independent now.

This commit is contained in:
OBattler
2017-06-15 06:34:08 +02:00
parent 12e1e8dfa7
commit e4c08cf594
6 changed files with 99 additions and 13 deletions

26
src/WIN/plat_ui.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef __unix
extern void plat_msgbox_error(int i);
extern wchar_t *plat_get_string_from_id(int i);
#ifndef IDS_2219
#define IDS_2219 2219
#endif
#ifndef IDS_2077
#define IDS_2077 2077
#endif
#ifndef IDS_2078
#define IDS_2078 2078
#endif
#ifndef IDS_2079
#define IDS_2079 2079
#endif
#endif
extern void plat_msgbox_fatal(char *string);
extern void get_executable_name(wchar_t *s, int size);
extern void set_window_title(wchar_t *s);
extern void startblit(void);
extern void endblit(void);

View File

@@ -49,6 +49,7 @@
#include "plat_mouse.h"
#include "plat_midi.h"
#include "plat_thread.h"
#include "plat_ui.h"
#include "win.h"
#include "win_cgapal.h"
@@ -525,12 +526,12 @@ void create_removable_disk_submenu(HMENU m, int id)
AppendMenu(m, MF_STRING, IDM_RDISK_IMAGE_WP | id, win_language_get_string_from_id(2220));
}
void get_executable_name(WCHAR *s, int size)
void get_executable_name(wchar_t *s, int size)
{
GetModuleFileName(hinstance, s, size);
}
void set_window_title(WCHAR *s)
void set_window_title(wchar_t *s)
{
if (video_fullscreen)
return;

View File

@@ -83,8 +83,8 @@ extern void joystickconfig_open(HWND hwnd, int joy_nr, int type);
extern int getfile(HWND hwnd, char *f, char *fn);
extern int getsfile(HWND hwnd, char *f, char *fn);
extern void get_executable_name(WCHAR *s, int size);
extern void set_window_title(WCHAR *s);
extern void get_executable_name(wchar_t *s, int size);
extern void set_window_title(wchar_t *s);
extern void startblit(void);
extern void endblit(void);

View File

@@ -20,6 +20,7 @@
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#include <shlobj.h>
#undef BITMAP
#include <commdlg.h>
@@ -27,6 +28,7 @@
#include "../ibm.h"
#include "../device.h"
#include "../ide.h"
#include "plat_ui.h"
#include "win.h"
#include "win_language.h"
@@ -82,6 +84,11 @@ LPTSTR win_language_get_string_from_id(int i)
return lpResourceString[i - 2048];
}
wchar_t *plat_get_string_from_id(int i)
{
return (wchar_t *) win_language_get_string_from_id(i);
}
LPTSTR win_language_get_string_from_string(char *str)
{
return lpResourceString[atoi(str) - 2048];
@@ -117,6 +124,11 @@ void msgbox_error(HWND hwndParent, int i)
MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[1], MB_OK | MB_ICONWARNING);
}
void plat_msgbox_error(int i)
{
msgbox_error(ghwnd, i);
}
void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr)
{
MessageBox(hwndParent, wstr, lpResourceString[1], MB_OK | MB_ICONWARNING);
@@ -139,6 +151,11 @@ void msgbox_fatal(HWND hwndParent, char *string)
free(lptsTemp);
}
void plat_msgbox_fatal(char *string)
{
msgbox_fatal(ghwnd, string);
}
int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save)
{
OPENFILENAME ofn; /* common dialog box structure */
@@ -207,3 +224,47 @@ int file_dlg_st(HWND hwnd, int i, char *fn, int save)
{
return file_dlg(hwnd, win_language_get_string_from_id(i), fn, save);
}
static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARAM lpData)
{
if(uMsg == BFFM_INITIALIZED)
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}
return 0;
}
WCHAR path[MAX_PATH];
wchar_t *BrowseFolder(wchar_t *saved_path)
{
BROWSEINFO bi = { 0 };
bi.lpszTitle = L"Browse for folder...";
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) saved_path;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl != 0)
{
/* Get the name of the folder and put it in path. */
SHGetPathFromIDList(pidl, path);
/* Free memory used. */
#if 0
IMalloc *imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(pidl);
imalloc->Release();
}
#endif
free(pidl);
return path;
}
return L"";
}