Various Win32 fixes and additions
This commit is contained in:
parent
c2591baa20
commit
d3f8721d14
BIN
ogl_editor/data/windows/appicon.ico
Normal file
BIN
ogl_editor/data/windows/appicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 345 KiB |
193
ogl_editor/data/windows/editor.rc
Normal file
193
ogl_editor/data/windows/editor.rc
Normal file
@ -0,0 +1,193 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Norwegian (Bokmal) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NOR)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_NORWEGIAN, SUBLANG_NORWEGIAN_BOKMAL
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_ACCELERATOR ACCELERATORS
|
||||
BEGIN
|
||||
"B", ID_EDIT_BIAS, VIRTKEY, CONTROL, NOINVERT
|
||||
"C", ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
|
||||
"X", ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
|
||||
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
|
||||
"Z", ID_EDIT_REDO, VIRTKEY, SHIFT, CONTROL, NOINVERT
|
||||
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL, NOINVERT
|
||||
"O", ID_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
|
||||
"S", ID_FILE_SAVE, VIRTKEY, CONTROL, NOINVERT
|
||||
"E", ID_FILE_REMOTEEXPORT, VIRTKEY, CONTROL, NOINVERT
|
||||
"A", ID_EDIT_SELECT_ALL, VIRTKEY, CONTROL, NOINVERT
|
||||
"T", ID_EDIT_SELECTTRACK, VIRTKEY, CONTROL, NOINVERT
|
||||
"R", ID_EDIT_SETROWS, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_PRIOR, ID_EDIT_BOOKMARK_PREV, VIRTKEY, ALT, NOINVERT
|
||||
VK_NEXT, ID_EDIT_BOOKMARK_NEXT, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "New\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM "&Open\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||
MENUITEM "Save &As", ID_FILE_SAVE_AS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Remote &Export\tCtrl+E", ID_FILE_REMOTEEXPORT
|
||||
POPUP "Recent &Files"
|
||||
BEGIN
|
||||
MENUITEM "No recent files", ID_RECENTFILES_NORECENTFILES, GRAYED
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_FILE_EXIT
|
||||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "Undo\tCtrl+Z", ID_EDIT_UNDO
|
||||
MENUITEM "Redo\tCtrl+Shift+Z", ID_EDIT_REDO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY
|
||||
MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT
|
||||
MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE
|
||||
MENUITEM "Clear\tDel", ID_EDIT_CLEAR
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select All\tCtrl+A", ID_EDIT_SELECTALL
|
||||
MENUITEM "Select Track\tCtrl+T", ID_EDIT_SELECTTRACK
|
||||
MENUITEM "Select Row", ID_EDIT_SELECTROW
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Bias Selection\tCtrl+B", ID_EDIT_BIAS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Set Rows\tCtrl+R", ID_EDIT_SETROWS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Previous Bookmark\tAlt+PgDn", ID_EDIT_BOOKMARK_PREV
|
||||
MENUITEM "Next Bookmark\tAlt+PgUp", ID_EDIT_BOOKMARK_NEXT
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_SETROWS DIALOGEX 0, 0, 129, 27
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Set Rows"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
EDITTEXT IDC_SETROWS_EDIT,7,6,59,12,ES_AUTOHSCROLL | ES_NUMBER
|
||||
DEFPUSHBUTTON "OK",IDOK,72,6,50,14
|
||||
END
|
||||
|
||||
IDD_BIASSELECTION DIALOGEX 0, 0, 129, 27
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Bias Selection"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
EDITTEXT IDC_BIASSELECTION_EDIT,7,6,59,12,ES_AUTOHSCROLL | ES_NUMBER
|
||||
DEFPUSHBUTTON "OK",IDOK,72,6,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_SETROWS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 122
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 20
|
||||
END
|
||||
|
||||
IDD_BIASSELECTION, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 122
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 20
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_APPLICATION ICON "appicon.ico"
|
||||
#endif // Norwegian (Bokmal) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
40
ogl_editor/data/windows/resource.h
Normal file
40
ogl_editor/data/windows/resource.h
Normal file
@ -0,0 +1,40 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by editor.rc
|
||||
//
|
||||
#define IDR_ACCELERATOR 101
|
||||
#define IDR_MENU 102
|
||||
#define IDD_SETROWS 103
|
||||
#define IDD_BIASSELECTION 104
|
||||
#define IDC_EDIT 1002
|
||||
#define IDC_SETROWS_EDIT 1002
|
||||
#define IDC_BIASSELECTION_EDIT 1003
|
||||
#define ID_FILE 40001
|
||||
#define ID_FILE_EXIT 40002
|
||||
#define ID_FILE_REMOTEEXPORT 40003
|
||||
#define ID_FILE_RECENTFILES 40004
|
||||
#define ID_RECENTFILES_NORECENTFILES 40010
|
||||
#define ID_RECENTFILES_FILE1 40011
|
||||
#define ID_RECENTFILES_FILE2 40012
|
||||
#define ID_RECENTFILES_FILE3 40013
|
||||
#define ID_RECENTFILES_FILE4 40014
|
||||
#define ID_RECENTFILES_FILE5 40015
|
||||
#define ID_EDIT 40020
|
||||
#define ID_EDIT_SETROWS 40021
|
||||
#define ID_EDIT_BIAS 40022
|
||||
#define ID_EDIT_SELECTALL 40023
|
||||
#define ID_EDIT_SELECTROW 40024
|
||||
#define ID_EDIT_SELECTTRACK 40025
|
||||
#define ID_EDIT_BOOKMARK_NEXT 40026
|
||||
#define ID_EDIT_BOOKMARK_PREV 40027
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40028
|
||||
#define _APS_NEXT_CONTROL_VALUE 1004
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
@ -887,7 +887,7 @@ bool Editor_keyDown(int key, int keyCode, int modifiers)
|
||||
s_editorData.trackData.editText = 0;
|
||||
}
|
||||
|
||||
if (key == 'i')
|
||||
if (key == 'i' || key == 'I')
|
||||
{
|
||||
struct track_key newKey;
|
||||
struct sync_track* track = tracks[active_track];
|
||||
|
||||
@ -131,6 +131,12 @@ bool RemoteConnection_createListner()
|
||||
struct sockaddr_in sin;
|
||||
int yes = 1;
|
||||
|
||||
#if defined(_WIN32)
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(2,0),&wsaData) != 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
s_serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (s_serverSocket == INVALID_SOCKET)
|
||||
@ -264,7 +270,7 @@ int RemoteConnection_recv(char* buffer, size_t length, int flags)
|
||||
|
||||
ret = recv(s_socket, buffer, (int)length, flags);
|
||||
|
||||
if (ret == 0)
|
||||
if (ret <= 0)
|
||||
{
|
||||
RemoteConnection_disconnect();
|
||||
return false;
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
#include <windowsx.h>
|
||||
#include <gl/gl.h>
|
||||
#include "../Editor.h"
|
||||
#include "resource.h"
|
||||
#include "afxres.h"
|
||||
#include <string.h>
|
||||
#include <Emgui.h>
|
||||
#include <GFXBackend.h>
|
||||
@ -82,15 +84,19 @@ bool createWindow(const char* title, int width, int height)
|
||||
rect.top = 0;
|
||||
rect.bottom= height;
|
||||
|
||||
EMGFXBackend_create();
|
||||
|
||||
s_instance = GetModuleHandle(0);
|
||||
memset(&wc, 0, sizeof(wc));
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wc.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wc.hInstance = s_instance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.lpszClassName = "RocketEditor";
|
||||
wc.hIcon = LoadIcon(s_instance, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU);
|
||||
|
||||
if (!RegisterClass(&wc))
|
||||
{
|
||||
@ -144,15 +150,72 @@ bool createWindow(const char* title, int width, int height)
|
||||
ShowWindow(s_window, SW_SHOW);
|
||||
SetForegroundWindow(s_window);
|
||||
SetFocus(s_window);
|
||||
|
||||
EMGFXBackend_create();
|
||||
EMGFXBackend_updateViewPort(width, height);
|
||||
Editor_create();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Window_setTitle(const char* title)
|
||||
{
|
||||
SetWindowText(s_window, title);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int s_modifier = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int onKeyDown(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int key = -1;
|
||||
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_SHIFT: s_modifier |= EMGUI_KEY_SHIFT; break;
|
||||
case VK_CONTROL: s_modifier |= EMGUI_KEY_CTRL; break;
|
||||
case VK_MENU : s_modifier |= EMGUI_KEY_ALT; break;
|
||||
case VK_LWIN :
|
||||
case VK_RWIN : s_modifier |= EMGUI_KEY_COMMAND; break;
|
||||
case VK_LEFT : key = EMGUI_ARROW_LEFT; break;
|
||||
case VK_UP : key = EMGUI_ARROW_UP; break;
|
||||
case VK_RIGHT : key = EMGUI_ARROW_RIGHT; break;
|
||||
case VK_DOWN : key = EMGUI_ARROW_DOWN; break;
|
||||
case VK_SPACE : key = ' '; break;
|
||||
|
||||
default:
|
||||
{
|
||||
wParam = MapVirtualKey((UINT)wParam, 2) & 0x0000ffff;
|
||||
wParam = (WPARAM) CharUpperA((LPSTR)wParam);
|
||||
|
||||
if((wParam >= 32 && wParam <= 126) ||
|
||||
(wParam >= 160 && wParam <= 255) )
|
||||
{
|
||||
return (int)wParam;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void onKeyUp(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_SHIFT: s_modifier &= ~EMGUI_KEY_SHIFT; break;
|
||||
case VK_CONTROL: s_modifier &= ~EMGUI_KEY_CTRL; break;
|
||||
case VK_MENU : s_modifier &= ~EMGUI_KEY_ALT; break;
|
||||
case VK_LWIN :
|
||||
case VK_RWIN : s_modifier &= ~EMGUI_KEY_COMMAND; break;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
@ -164,7 +227,7 @@ LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam
|
||||
else
|
||||
s_active = true;
|
||||
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
@ -189,6 +252,42 @@ LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
{
|
||||
int key = onKeyDown(wParam, lParam);
|
||||
|
||||
if (key != -1)
|
||||
{
|
||||
Emgui_sendKeyinput(key, s_modifier);
|
||||
Editor_keyDown(key, -1, s_modifier);
|
||||
Editor_update();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
{
|
||||
onKeyUp(wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case ID_FILE_OPEN:
|
||||
{
|
||||
Editor_menuEvent(EDITOR_MENU_OPEN);
|
||||
Editor_update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SYSCOMMAND:
|
||||
{
|
||||
switch (wParam)
|
||||
@ -211,6 +310,7 @@ LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam
|
||||
{
|
||||
EMGFXBackend_updateViewPort(LOWORD(lParam), HIWORD(lParam));
|
||||
Editor_setWindowSize(LOWORD(lParam), HIWORD(lParam));
|
||||
Editor_update();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -237,10 +337,6 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmndLine, i
|
||||
if (!createWindow("RocketEditor", 800, 600))
|
||||
return 0;
|
||||
|
||||
EMGFXBackend_create();
|
||||
Editor_create();
|
||||
Editor_update();
|
||||
|
||||
// Update timed function every 16 ms
|
||||
|
||||
SetTimer(s_window, 1, 16, timedCallback);
|
||||
|
||||
12
ogl_editor/src/windows/afxres.h
Normal file
12
ogl_editor/src/windows/afxres.h
Normal file
@ -0,0 +1,12 @@
|
||||
#include <windows.h>
|
||||
#define ID_FILE_NEW 0xE100
|
||||
#define ID_FILE_OPEN 0xE101
|
||||
#define ID_FILE_SAVE 0xE103
|
||||
#define ID_FILE_SAVE_AS 0xE104
|
||||
#define ID_EDIT_CLEAR 0xE120
|
||||
#define ID_EDIT_COPY 0xE122
|
||||
#define ID_EDIT_CUT 0xE123
|
||||
#define ID_EDIT_PASTE 0xE125
|
||||
#define ID_EDIT_SELECT_ALL 0xE12A
|
||||
#define ID_EDIT_UNDO 0xE12B
|
||||
#define ID_EDIT_REDO 0xE12C
|
||||
40
ogl_editor/src/windows/resource.h
Normal file
40
ogl_editor/src/windows/resource.h
Normal file
@ -0,0 +1,40 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by editor.rc
|
||||
//
|
||||
#define IDR_ACCELERATOR 101
|
||||
#define IDR_MENU 102
|
||||
#define IDD_SETROWS 103
|
||||
#define IDD_BIASSELECTION 104
|
||||
#define IDC_EDIT 1002
|
||||
#define IDC_SETROWS_EDIT 1002
|
||||
#define IDC_BIASSELECTION_EDIT 1003
|
||||
#define ID_FILE 40001
|
||||
#define ID_FILE_EXIT 40002
|
||||
#define ID_FILE_REMOTEEXPORT 40003
|
||||
#define ID_FILE_RECENTFILES 40004
|
||||
#define ID_RECENTFILES_NORECENTFILES 40010
|
||||
#define ID_RECENTFILES_FILE1 40011
|
||||
#define ID_RECENTFILES_FILE2 40012
|
||||
#define ID_RECENTFILES_FILE3 40013
|
||||
#define ID_RECENTFILES_FILE4 40014
|
||||
#define ID_RECENTFILES_FILE5 40015
|
||||
#define ID_EDIT 40020
|
||||
#define ID_EDIT_SETROWS 40021
|
||||
#define ID_EDIT_BIAS 40022
|
||||
#define ID_EDIT_SELECTALL 40023
|
||||
#define ID_EDIT_SELECTROW 40024
|
||||
#define ID_EDIT_SELECTTRACK 40025
|
||||
#define ID_EDIT_BOOKMARK_NEXT 40026
|
||||
#define ID_EDIT_BOOKMARK_PREV 40027
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40028
|
||||
#define _APS_NEXT_CONTROL_VALUE 1004
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user