Added window around windowed JA2

Replaced Windows console with freeware console implementation.  Activate in windowed mode with \
Added error and quit if JA2 started in window mode in >16bpp color depth
Fix to enemy sector investigation:  Was deducting from redshirts when elites investigated
Fix AWOL militia (need additional fix to prevent them from being redistributed during after reinforcements)
Fix to tanks to add them in their original spot when a new one cannot be found.  Should modify to remove old wreckage in this case.
AI no longer tries to fire mortar when no room for it
Tanks no longer try to throw knives


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1030 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Overhaul
2007-07-08 07:02:56 +00:00
parent 45b0868ace
commit d8145755c3
60 changed files with 9433 additions and 349 deletions
+81
View File
@@ -0,0 +1,81 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
#ifndef _COMBSTROUT_H_
#define _COMBSTROUT_H_
/////////////////////////////////////////////////////////////////////////////
// CComBSTROut - a class that inherits from CComBSTR and adds Out() method
// that should be used instead of & operator for 'out'
// function parameters
class CComBSTROut : public CComBSTR
{
public:
CComBSTROut()
{
}
/*explicit*/ CComBSTROut(int nSize) : CComBSTR(nSize)
{
}
/*explicit*/ CComBSTROut(int nSize, LPCOLESTR sz) : CComBSTR(nSize, sz)
{
}
/*explicit*/ CComBSTROut(LPCOLESTR pSrc) : CComBSTR(pSrc)
{
}
/*explicit*/ CComBSTROut(const CComBSTROut& src) : CComBSTR(src)
{
}
/*explicit*/ CComBSTROut(REFGUID src) : CComBSTR(src)
{
}
#ifndef OLE2ANSI
CComBSTROut(LPCSTR pSrc) : CComBSTR(pSrc)
{
}
CComBSTROut(int nSize, LPCSTR sz) : CComBSTR(nSize, sz)
{
}
#endif
~CComBSTROut()
{
CComBSTR::~CComBSTR();
}
BSTR* Out()
{
Empty();
return &m_str;
}
};
/////////////////////////////////////////////////////////////////////////////
#endif // _COMBSTROUT_H_
+109
View File
@@ -0,0 +1,109 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
#ifndef _COMVARIANTOUT_H_
#define _COMVARIANTOUT_H_
/////////////////////////////////////////////////////////////////////////////
// CComVariantOut - a class that inherits from CComVariant and adds Out()
// method that should be used instead of & operator for
// 'out' function parameters
class CComVariantOut : public CComVariant
{
public:
CComVariantOut()
{
}
~CComVariantOut()
{
CComVariant::~CComVariant();
}
CComVariantOut(const VARIANT& varSrc) : CComVariant(varSrc)
{
}
CComVariantOut(const CComVariant& varSrc) : CComVariant(varSrc)
{
}
CComVariantOut(BSTR bstrSrc) : CComVariant(bstrSrc)
{
}
CComVariantOut(LPCOLESTR lpszSrc) : CComVariant(lpszSrc)
{
}
#ifndef OLE2ANSI
CComVariantOut(LPCSTR lpszSrc) : CComVariant(lpszSrc)
{
}
#endif
CComVariantOut(bool bSrc) : CComVariant(bSrc)
{
}
CComVariantOut(int nSrc) : CComVariant(nSrc)
{
}
CComVariantOut(BYTE nSrc) : CComVariant(nSrc)
{
}
CComVariantOut(short nSrc) : CComVariant(nSrc)
{
}
CComVariantOut(long nSrc, VARTYPE m_varSrc = VT_I4) : CComVariant(nSrc, m_varSrc)
{
}
CComVariantOut(float fltSrc) : CComVariant(fltSrc)
{
}
CComVariantOut(double dblSrc) : CComVariant(dblSrc)
{
}
CComVariantOut(CY cySrc) : CComVariant(cySrc)
{
}
CComVariantOut(IDispatch* pSrc) : CComVariant(pSrc)
{
}
CComVariantOut(IUnknown* pSrc) : CComVariant(pSrc)
{
}
public:
VARIANT* Out()
{
Clear();
return this;
}
};
/////////////////////////////////////////////////////////////////////////////
#endif // _COMVARIANTOUT_H_
+4560
View File
File diff suppressed because it is too large Load Diff
+744
View File
@@ -0,0 +1,744 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Console.h - console class declaration
#pragma once
#include <string>
#include <vector>
using namespace std;
//#include "include/FreeImagePlus.h"
typedef basic_string<TCHAR> tstring;
#define WM_INPUTREADY WM_USER + 1
// tray icon message
#define WM_TRAY_NOTIFY WM_USER + 0x123
#define TRAY_ICON_ID 1
// timer #defines
#define TIMER_REPAINT_CHANGE 42 // timer that is started after there
// were some changes in the console
#define TIMER_REPAINT_MASTER 43 // master timer (needed to repaint
// for some DOS programs, can be
// disabled for lower CPU usage)
#define TIMER_SHOW_HIDE_CONSOLE 100 // used to hide console window when
// starting shell process after a
// defined period of time (some
// shells, like 4NT need console
// window visible during startup for
// all init options to work properly
// transparency #defines
#define TRANSPARENCY_NONE 0
#define TRANSPARENCY_ALPHA 1
#define TRANSPARENCY_COLORKEY 2
#define TRANSPARENCY_FAKE 3
// cusror style #defines
#define CURSOR_STYLE_NONE 0
#define CURSOR_STYLE_XTERM 1
#define CURSOR_STYLE_BLOCK 2
#define CURSOR_STYLE_NBBLOCK 3
#define CURSOR_STYLE_PULSEBLOCK 4
#define CURSOR_STYLE_BAR 5
#define CURSOR_STYLE_CONSOLE 6
#define CURSOR_STYLE_NBHLINE 7
#define CURSOR_STYLE_HLINE 8
#define CURSOR_STYLE_VLINE 9
#define CURSOR_STYLE_RECT 10
#define CURSOR_STYLE_NBRECT 11
#define CURSOR_STYLE_PULSERECT 12
#define CURSOR_STYLE_FADEBLOCK 13
// docking #defines
#define DOCK_NONE 0
#define DOCK_TOP_LEFT 1
#define DOCK_TOP_RIGHT 2
#define DOCK_BOTTOM_RIGHT 3
#define DOCK_BOTTOM_LEFT 4
// Z-order #defines
#define Z_ORDER_REGULAR 0
#define Z_ORDER_ONTOP 1
#define Z_ORDER_ONBOTTOM 2
// window border defines
#define BORDER_NONE 0
#define BORDER_REGULAR 1
#define BORDER_THIN 2
// window background style
#define BACKGROUND_STYLE_RESIZE 0
#define BACKGROUND_STYLE_CENTER 1
#define BACKGROUND_STYLE_TILE 2
// taskbar button defines
#define TASKBAR_BUTTON_NORMAL 0
#define TASKBAR_BUTTON_HIDE 1
#define TASKBAR_BUTTON_TRAY 2
// new configuration auto-reload defines
#define RELOAD_NEW_CONFIG_PROMPT 0
#define RELOAD_NEW_CONFIG_YES 1
#define RELOAD_NEW_CONFIG_NO 2
#define TEXT_SELECTION_NONE 0
#define TEXT_SELECTION_SELECTING 1
#define TEXT_SELECTION_SELECTED 2
/////////////////////////////////////////////////////////////////////////////
// Console class
class Console {
public: // ctor/dtor
Console(LPCTSTR szConfigFile, LPCTSTR szShellCmdLine, LPCTSTR szConsoleTitle, LPCTSTR pszReloadNewConfig);
~Console();
public:
// creates and shows Console window
BOOL Create(TCHAR* pszConfigPath);
private:
////////////////////
// message handlers
////////////////////
////////////////////////////////
// windows destruction messages
// destroys GDI stuff and posts a quit message
void OnDestroy();
// deletes Console object
void OnNcDestroy();
/////////////////////
// painting messages
// handles painting from off-screen buffers
void OnPaint();
// handles master and 'change' timers
void OnPaintTimer();
// handles cursor timer (for animated cursors)
void OnCursorTimer();
/////////////////////////
// window state messages
// handles window position changes (for snapping to desktop edges)
void OnWindowPosChanging(WINDOWPOS* lpWndPos);
// handles activation message (used for setting alpha transparency and cursor states)
void OnActivateApp(BOOL bActivate, DWORD dwFlags);
// handles vertical scrolling
void OnVScroll(WPARAM wParam);
// handles keyboard layout change, posts the same message to the windows console window
void OnInputLangChangeRequest(WPARAM wParam, LPARAM lParam);
//////////////////
// mouse messages
// handles text selection start and window mouse drag start
void OnLButtonDown(UINT uiFlags, POINTS points);
// handles text selection end, window mouse drag end and text copy
void OnLButtonUp(UINT uiFlags, POINTS points);
// toggles always on top flag
void OnLButtonDblClick(UINT uiFlags, POINTS points);
// pops up the Console menu
void OnRButtonUp(UINT uiFlags, POINTS points);
// pastes text from clipboard
void OnMButtonDown(UINT uiFlags, POINTS points);
// handles mouse movement for text selection and window mouse drag
void OnMouseMove(UINT uiFlags, POINTS points);
// handles start/stop mouse drag for window border
void OnSetCursor(WORD wHitTest, WORD wMouseMessage);
// handles text input
void OnChar(WORD mychar);
wstring Input;
//////////////////
// other messages
// called before the Console menu or system menu pops up
// (populates config files submenu with filenames)
void OnInitMenuPopup(HMENU hMenu, UINT uiPos, BOOL bSysMenu);
// handles drag-n-dropped filenames
void OnDropFiles(HDROP hDrop);
// handles commands from the Console popup menu
BOOL OnCommand(WPARAM wParam, LPARAM lParam);
// handles commands from the system popup menu
BOOL OnSysCommand(WPARAM wParam, LPARAM lParam);
// handles tray icon messages
void OnTrayNotify(WPARAM wParam, LPARAM lParam);
// handles WM_SETTINGCHANGE (we handle only wallpaper changes here)
// void OnWallpaperChanged(const TCHAR* pszFilename);
private:
///////////////////////////////////////////
// Console window creation/setup functions
///////////////////////////////////////////
// gets Console options
BOOL GetOptions();
// registers Console window classes
BOOL RegisterWindowClasses();
// adds stuff to system and popup menus
BOOL SetupMenus();
// creates Console window
BOOL CreateConsoleWindow();
// creates new Console font
void CreateNewFont();
// creates new background brush
void CreateNewBrush();
// creates the cursor
void CreateCursor();
// creates offscreen painting buffers
void CreateOffscreenBuffers();
// creates background bitmap
void CreateBackgroundBitmap();
// called by the ::EnumDisplayMonitors to create background for each display
// static BOOL CALLBACK BackgroundEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
// gets character width and height
void GetTextSize();
// gets window borders (X, Y and caption sizes)
void GetBordersDimensions();
// calculates window and client area sizes
void CalcWindowSize();
// sets up window transparency (alpha, color key, fake)
// void SetWindowTransparency();
// sets scrollbar stuff
void SetScrollbarStuff();
// sets default console colors
void SetDefaultConsoleColors();
// sets window size and position
void SetWindowSizeAndPosition();
// sets Console's big, small and tray icons
void SetWindowIcons();
// sets up traybar icon
BOOL SetTrayIcon(DWORD dwMessage);
// destroys Console cursor
void DestroyCursor();
// opens the configuration file in a text editor
void EditConfigFile();
// reloads Console settings
void ReloadSettings();
/////////////////////////////
// windows console functions
/////////////////////////////
// allocates the console and starts the command shell
BOOL StartShellProcess();
// refreshes m_hStdOutFresh handle
void RefreshStdOut();
// gets a fresh console output
void RefreshScreenBuffer();
// sets initial windows console size
void InitConsoleWndSize(DWORD dwColumns);
// resizes the windows console
void ResizeConsoleWindow();
// Allocates the screen buffer
void AllocateBuffer();
//////////////////////
// painting functions
//////////////////////
// repaints the memory hdc
void RepaintWindow();
// repaints the memory hdc (paint only changes)
void RepaintWindowChanges();
// draws the cursor
void DrawCursor(BOOL bOnlyCursor = FALSE);
// two helper functions for DrawCursor method
// returns cursor rectangle
inline void GetCursorRect(RECT& rectCursor);
// draws cursor background and returns the cursor rectangle
inline void DrawCursorBackground(RECT& rectCursor);
// clears text selection
void ClearSelection();
// returns the console text change rate since the last painting
// (using this value we decide whether to repaint entire window
// or just the changes)
DWORD GetChangeRate();
//////////////////////////
// window state functions
//////////////////////////
// shows/hides Console window
void ShowHideWindow();
// shows/hides windows console window
void ShowHideConsole();
// shows/hides windows console window after a timeout (used during
// shell startup)
void ShowHideConsoleTimeout();
// toggles 'always on top' status
void ToggleWindowOnTop();
//////////////////
// menu functions
//////////////////
// called by OnCommand and OnSysCommand to handle menu commands
BOOL HandleMenuCommand(DWORD dwID);
// updates popup and system menus for 'always on top' status
void UpdateOnTopMenuItem();
// updates popup and system menus for 'hide console' status
void UpdateHideConsoleMenuItem();
// updates configuration files submenu
void UpdateConfigFilesSubmenu();
///////////////////////
// clipboard functions
///////////////////////
// copies selected text to the clipboard
void CopyTextToClipboard();
// pastes text from the clipboard
void PasteClipoardText();
//////////////////
// misc functions
//////////////////
// shows Readme.txt file
void ShowReadmeFile();
// shows about dialog
void About();
// sends text to the windows console
void SendTextToConsole(const wchar_t *pszText);
// returns the full filename
tstring GetFullFilename(const tstring& strFilename);
// gets a desktop rectangle
void GetDesktopRect(RECT& rectDesktop);
// Pulls the text from the stdout or stderr handle (both are the same) and sends it to the console
void AddOutput();
///////////////////////
// 'gearbox' functions
///////////////////////
// Console window procedure
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
// shell activities monitor
static DWORD WINAPI MonitorThreadStatic(LPVOID lpParam);
DWORD MonitorThread();
// CTRL+C, CTRL+BREAK handler
static BOOL WINAPI CtrlHandler(DWORD dwCtrlType);
public: // public data
// Console window handle
HWND m_hWnd;
// console colors
COLORREF m_arrConsoleColors[16];
private: // private data
// readem filename
tstring m_strReadmeFile;
BOOL m_bInitializing;
BOOL m_bReloading;
tstring m_strConfigFile;
tstring m_strConfigEditor;
tstring m_strConfigEditorParams;
// one of the RELOAD_NEW_CONFIG_* constants
// - specifies relaod behaviour when a new configuration is selected
// (auto reload, don't reload, ask user)
DWORD m_dwReloadNewConfigDefault;
DWORD m_dwReloadNewConfig;
tstring m_strShell;
tstring m_strShellCmdLine;
// handle to invisible window - used for hiding the taskbar button in tray and 'hidden' modes
HWND m_hwndInvisParent;
// memory device context that holds console output image
HDC m_hdcConsole;
// memory device context for an off-screen window buffer (used to
// compose an image from m_hdcConsole and m_hdcSelection if text
// selection is active)
HDC m_hdcWindow;
// a bitmap used for drawing in the console memory DC
HBITMAP m_hbmpConsole;
HBITMAP m_hbmpConsoleOld;
// a bitmap used for drawing in the window memory DC
HBITMAP m_hbmpWindow;
HBITMAP m_hbmpWindowOld;
// brush for painting background
HBRUSH m_hBkBrush;
// master repaint timer interval (runs independent of changes in the
// console)
DWORD m_dwMasterRepaintInt;
// change repaint timer interval (when a change occurs, repainting
// will be postponed for this interval)
DWORD m_dwChangeRepaintInt;
// icon filename
tstring m_strIconFilename;
// program icons
HICON m_hSmallIcon;
HICON m_hBigIcon;
// popup menu
HMENU m_hPopupMenu;
// system (taskbar button) menu
HMENU m_hSysMenu;
// submenu for the XML (config) files
HMENU m_hConfigFilesMenu;
// set to TRUE if the popup menu is disabled
BOOL m_bPopupMenuDisabled;
// Console window title variables
// holds the default console title ("console" or the one passed in the cmdline param)
tstring m_strWindowTitleDefault;
// holds the window title (default title, or the one from the config file)
tstring m_strWindowTitle;
// holds the current window title
tstring m_strWindowTitleCurrent;
// font data
tstring m_strFontName;
DWORD m_dwFontSize;
BOOL m_bBold;
BOOL m_bItalic;
BOOL m_bUseFontColor;
COLORREF m_crFontColor;
HFONT m_hFont;
HFONT m_hFontOld;
// window X and Y positions
int m_nX;
int m_nY;
// client area inside border (gives a more 'relaxed' look to windows)
int m_nInsideBorder;
// window width and height
int m_nWindowWidth;
int m_nWindowHeight;
// window border sizes
int m_nXBorderSize;
int m_nYBorderSize;
int m_nCaptionSize;
// client area widht/height
int m_nClientWidth;
int m_nClientHeight;
// char height and width (used in window repainting)
// Note: width is used only for fixed-pitch fonts to speed up
// repainting
int m_nCharHeight;
int m_nCharWidth;
// window border type
// 0 - none
// 1 - regular window
// 2 - 1-pixel thin border
DWORD m_dwWindowBorder;
// scrollbar stuff
BOOL m_bShowScrollbar;
int m_nScrollbarStyle;
COLORREF m_crScrollbarColor;
int m_nScrollbarWidth;
int m_nScrollbarButtonHeight;
int m_nScrollbarThunmbHeight;
// what to do with the taskbar button
// if the taskbar button is hidden, or placed in the traybar, you
// can't ALT-TAB to console (take care when using with color key
// transparency :-)
// 0 - nothing
// 1 - hide it
// 2 - put icon to traybar
DWORD m_dwTaskbarButton;
// set to TRUE if the window can be dragged by left-click hold
BOOL m_bMouseDragable;
// snap distance
int m_nSnapDst;
// window docking position
// 0 - no dock
// 1 - top left
// 2 - top right
// 3 - bottom right
// 4 - bottom left
DWORD m_dwDocked;
// window Z-ordering
// 0 - regular
// 1 - always on top
// 2 - always on bottom
DWORD m_dwOriginalZOrder;
DWORD m_dwCurrentZOrder;
// Win2000/XP transparency
// 0 - none
// 1 - alpha blending
// 2 - colorkey
// 3 - fake transparency
DWORD m_dwTransparency;
// alpha value for alpha blending (Win2000 and later only!)
BYTE m_byAlpha;
// alpha value for inactive window
BYTE m_byInactiveAlpha;
COLORREF m_crBackground;
COLORREF m_crConsoleBackground;
// this is used for tinting background images and fake transparencies
BOOL m_bTintSet;
BYTE m_byTintOpacity;
BYTE m_byTintR;
BYTE m_byTintG;
BYTE m_byTintB;
// used when background is an image
BOOL m_bBitmapBackground;
tstring m_strBackgroundFile;
HDC m_hdcBackground;
HBITMAP m_hbmpBackground;
HBITMAP m_hbmpBackgroundOld;
// background attributes
// one of BACKGROUND_STYLE_ #defines
DWORD m_dwBackgroundStyle;
// set to true for relative background
BOOL m_bRelativeBackground;
// set to true to extend the background to all monitors
BOOL m_bExtendBackground;
// offsets used for multiple monitors and relative backgrounds (fake transparency, too)
int m_nBackgroundOffsetX;
int m_nBackgroundOffsetY;
// used for showing/hiding main window
BOOL m_bHideWindow;
// set to TRUE when the real console is hidden
BOOL m_bHideConsole;
// timeout used when hiding console window for the first time (some
// shells need console window visible during startup)
DWORD m_dwHideConsoleTimeout;
// if set to TRUE, Console will be started minimized
BOOL m_bStartMinimized;
// cursor style
// 0 - none
// 1 - XTerm
// 2 - block cursor
// 3 - bar cursor
// 4 - console cursor
// 5 - horizontal line
// 6 - vertical line
// 7 - pulse rect
// 8 - fading block
DWORD m_dwCursorStyle;
COLORREF m_crCursorColor;
// console screen buffer info for cursor
CONSOLE_SCREEN_BUFFER_INFO m_csbiCursor;
// wether console cursor is visible or not
BOOL m_bCursorVisible;
class Cursor* m_pCursor;
// mouse cursor offset within the window (used for moving the window)
POINT m_mouseCursorOffset;
/////////////////////
// console stuff
// console window handle
HWND m_hWndConsole;
// console screen buffer info for console repainting
CONSOLE_SCREEN_BUFFER_INFO m_csbiConsole;
// console stdouts
HANDLE m_hStdOut;
HANDLE m_hStdOutFresh;
// set when quitting the application
HANDLE m_hQuitEvent;
// set by monitor thread when detects console process exit
HANDLE m_hConsoleProcess;
// handle to monitor thread
HANDLE m_hMonitorThread;
// console rows & columns
DWORD m_dwRows;
DWORD m_dwColumns;
DWORD m_dwBufferRows;
BOOL m_bUseTextBuffer;
// set to one of TEXT_SELECTION_ #defines
int m_nTextSelection;
// X Windows style copy-on-select
BOOL m_bCopyOnSelect;
// Inverse the shift behaviour for selecting and dragging
BOOL m_bInverseShift;
COORD m_coordSelOrigin;
RECT m_rectSelection;
HDC m_hdcSelection;
HBITMAP m_hbmpSelection;
HBITMAP m_hbmpSelectionOld;
HBRUSH m_hbrushSelection;
CHAR_INFO* m_pScreenBuffer;
CHAR_INFO* m_pScreenBufferNew;
DWORD m_nTextColor;
DWORD m_nTextBgColor;
// Console window class names
static const TCHAR m_szConsoleClass[];
static const TCHAR m_szHiddenParentClass[];
// win console window title
static const tstring m_strWinConsoleTitle;
};
/////////////////////////////////////////////////////////////////////////////
+207
View File
@@ -0,0 +1,207 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Neutral resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(1250)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 146, 87
STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_CENTER | WS_POPUP |
WS_CAPTION | WS_SYSMENU
CAPTION "About Console"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,66,50,14
LTEXT "Console v1.5",IDC_STATIC,51,11,42,8
LTEXT "Copyright© 2001-2005 Marko Bozikovic",IDC_STATIC,9,30,
127,8
LTEXT "bozho@kset.org",IDC_STATIC,46,45,53,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 139
TOPMARGIN, 7
BOTTOMMARGIN, 80
END
END
#endif // APSTUDIO_INVOKED
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Neutral (Default) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
#ifdef _WIN32
LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
#pragma code_page(1250)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
//IDI_ICON2 ICON DISCARDABLE "Console.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_POPUP_MENU MENU DISCARDABLE
BEGIN
POPUP " "
BEGIN
// MENUITEM "Read&me", ID_SHOW_README_FILE
MENUITEM "&About Console", ID_ABOUT
MENUITEM SEPARATOR
MENUITEM "&Copy", ID_COPY
MENUITEM "&Paste", ID_PASTE
MENUITEM SEPARATOR
// MENUITEM "Always on &top", ID_TOGGLE_ONTOP
// MENUITEM "&Hide console", ID_HIDE_CONSOLE
// MENUITEM SEPARATOR
// MENUITEM "&Select configuration file", ID_SEL_CONFIG_FILE
// MENUITEM "&Edit configuration file", ID_EDIT_CONFIG_FILE
// MENUITEM "&Reload settings", ID_RELOAD_SETTINGS
// MENUITEM SEPARATOR
MENUITEM "E&xit", ID_EXIT_CONSOLE
END
END
#endif // Neutral (Default) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Croatian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_HRV)
#ifdef _WIN32
LANGUAGE LANG_CROATIAN, SUBLANG_DEFAULT
#pragma code_page(1250)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,5,0,351
PRODUCTVERSION 1,5,0,351
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "Comments", "A cool console window :-)\0"
VALUE "CompanyName", "Ingenuity Unlimited Ltd.\0"
VALUE "FileDescription", "Console\0"
VALUE "FileVersion", "1.5, Build 351 2005.09.22\0"
VALUE "InternalName", "Console\0"
VALUE "LegalCopyright", "Copyright © 2001-2004 Marko Bozikovic\0"
VALUE "LegalTrademarks", "Copyright © 2001-2004 Marko Bozikovic\0"
VALUE "OriginalFilename", "Console.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Console\0"
VALUE "ProductVersion", "1.5.00.351\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0, 1200
END
END
#endif // !_MAC
#endif // Croatian resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
+319
View File
@@ -0,0 +1,319 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="Console_2005Express"
ProjectGUID="{F962CFA1-2215-4124-938F-253973A27591}"
RootNamespace="Console"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops;..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug/Console.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/Console.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1050"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="comctl32.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/Console.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops;..\ja2_2005Express.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release/Console.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="c:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\src\mfc"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Release/Console.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1050"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
AdditionalDependencies="comctl32.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/Console.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="Console.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="Cursors.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="Dialogs.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="FileStream.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="ComBSTROut.h"
>
</File>
<File
RelativePath="ComVariantOut.h"
>
</File>
<File
RelativePath="Console.h"
>
</File>
<File
RelativePath="Cursors.h"
>
</File>
<File
RelativePath="Dialogs.h"
>
</File>
<File
RelativePath="FileStream.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
<File
RelativePath="Console.ico"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+842
View File
@@ -0,0 +1,842 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Cursors.h - cursor classes
//#include "stdafx.h"
#include <Windows.h>
#include <tchar.h>
#include "Cursors.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// XTermCursor
XTermCursor::XTermCursor(HWND hwndConsole, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndConsole, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
, m_hInactiveBrush(::CreateSolidBrush(crCursorColor))
{
}
XTermCursor::~XTermCursor() {
::DeleteObject(m_hActiveBrush);
::DeleteObject(m_hInactiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void XTermCursor::Draw(LPRECT pRect) {
if (m_bActive) {
::FillRect(m_hdcWindow, pRect, m_hActiveBrush);
} else {
::FrameRect(m_hdcWindow, pRect, m_hInactiveBrush);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void XTermCursor::PrepareNext() {
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BlockCursor
BlockCursor::BlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
, m_bVisible(TRUE)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 750, NULL);
}
BlockCursor::~BlockCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void BlockCursor::Draw(LPRECT pRect) {
if (m_bActive && m_bVisible) {
::FillRect(m_hdcWindow, pRect, m_hActiveBrush);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void BlockCursor::PrepareNext() {
m_bVisible = !m_bVisible;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// NBBlockCursor
NBBlockCursor::NBBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
{
}
NBBlockCursor::~NBBlockCursor() {
::DeleteObject(m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void NBBlockCursor::Draw(LPRECT pRect) {
::FillRect(m_hdcWindow, pRect, m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void NBBlockCursor::PrepareNext() {
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// PulseBlockCursor
PulseBlockCursor::PulseBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
, m_nSize(0)
, m_nMaxSize(0)
, m_nStep(0)
{
::ZeroMemory(&m_rect, sizeof(RECT));
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 100, NULL);
}
PulseBlockCursor::~PulseBlockCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void PulseBlockCursor::Draw(LPRECT pRect) {
// this is called only once, to set the size of the cursor
if (m_nMaxSize == 0) {
if ((pRect->right - pRect->left) < (pRect->bottom - pRect->top)) {
m_nMaxSize = (pRect->right - pRect->left) >> 1;
} else {
m_nMaxSize = (pRect->bottom - pRect->top) >> 1;
}
}
if (m_bActive) {
RECT rect;
::CopyMemory(&rect, pRect, sizeof(RECT));
rect.left += m_nSize;
rect.top += m_nSize;
rect.right -= m_nSize;
rect.bottom -= m_nSize;
::FillRect(m_hdcWindow, &rect, m_hActiveBrush);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void PulseBlockCursor::PrepareNext() {
if (m_nSize == 0) {
m_nStep = 1;
} else if (m_nSize == m_nMaxSize) {
m_nStep = -1;
}
m_nSize += m_nStep;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BarCursor
BarCursor::BarCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hPen(::CreatePen(PS_SOLID, 1, crCursorColor))
, m_bVisible(TRUE)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 750, NULL);
}
BarCursor::~BarCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hPen);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void BarCursor::Draw(LPRECT pRect) {
if (m_bActive && m_bVisible) {
HPEN hOldPen = (HPEN)::SelectObject(m_hdcWindow, m_hPen);
::MoveToEx(m_hdcWindow, pRect->left, pRect->top, NULL);
::LineTo(m_hdcWindow, pRect->left, pRect->bottom);
::SelectObject(m_hdcWindow, hOldPen);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void BarCursor::PrepareNext() {
m_bVisible = !m_bVisible;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// ConsoleCursor
ConsoleCursor::ConsoleCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hStdOut(::CreateFile(_T("CONOUT$"), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0))
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
, m_bVisible(TRUE)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 750, NULL);
}
ConsoleCursor::~ConsoleCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hActiveBrush);
::CloseHandle(m_hStdOut);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void ConsoleCursor::Draw(LPRECT pRect) {
RECT rect;
::CopyMemory(&rect, pRect, sizeof(RECT));
if (m_bActive && m_bVisible) {
#if 0
CONSOLE_CURSOR_INFO csi;
::GetConsoleCursorInfo(m_hStdOut, &csi);
rect.top += (rect.bottom - rect.top) * (100-csi.dwSize)/100;
#else
rect.top += (rect.bottom - rect.top) * 80 / 100;
#endif
::FillRect(m_hdcWindow, &rect, m_hActiveBrush);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void ConsoleCursor::PrepareNext() {
m_bVisible = !m_bVisible;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// NBHLineCursor
NBHLineCursor::NBHLineCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hPen(::CreatePen(PS_SOLID, 1, crCursorColor))
{
}
NBHLineCursor::~NBHLineCursor() {
::DeleteObject(m_hPen);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void NBHLineCursor::Draw(LPRECT pRect) {
HPEN hOldPen = (HPEN)::SelectObject(m_hdcWindow, m_hPen);
::MoveToEx(m_hdcWindow, pRect->left, pRect->bottom-1, NULL);
::LineTo(m_hdcWindow, pRect->right, pRect->bottom-1);
::SelectObject(m_hdcWindow, hOldPen);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void NBHLineCursor::PrepareNext() {
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// HLineCursor
HLineCursor::HLineCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hPen(::CreatePen(PS_SOLID, 1, crCursorColor))
, m_nSize(0)
, m_nPosition(0)
, m_nStep(0)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 100, NULL);
}
HLineCursor::~HLineCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hPen);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void HLineCursor::Draw(LPRECT pRect) {
// this is called only once, to set the size of the cursor
if (m_nSize != (pRect->bottom - pRect->top - 1)) {
m_nSize = pRect->bottom - pRect->top - 1;
m_nPosition = 0;
m_nStep = 1;
}
if (m_bActive) {
HPEN hOldPen = (HPEN)::SelectObject(m_hdcWindow, m_hPen);
::MoveToEx(m_hdcWindow, pRect->left, pRect->top + m_nPosition, NULL);
::LineTo(m_hdcWindow, pRect->right, pRect->top + m_nPosition);
::SelectObject(m_hdcWindow, hOldPen);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void HLineCursor::PrepareNext() {
if (m_nPosition == 0) {
m_nStep = 1;
} else if (m_nPosition == m_nSize) {
m_nStep = -1;
}
m_nPosition += m_nStep;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// VLineCursor
VLineCursor::VLineCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hPen(::CreatePen(PS_SOLID, 1, crCursorColor))
, m_nSize(0)
, m_nPosition(0)
, m_nStep(0)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 100, NULL);
}
VLineCursor::~VLineCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hPen);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void VLineCursor::Draw(LPRECT pRect) {
// this is called only once, to set the size of the cursor
if (m_nSize != (pRect->right - pRect->left - 1)) {
m_nSize = pRect->right - pRect->left - 1;
m_nPosition = 0;
m_nStep = 1;
}
if (m_bActive) {
HPEN hOldPen = (HPEN)::SelectObject(m_hdcWindow, m_hPen);
::MoveToEx(m_hdcWindow, pRect->left + m_nPosition, pRect->top, NULL);
::LineTo(m_hdcWindow, pRect->left + m_nPosition, pRect->bottom);
::SelectObject(m_hdcWindow, hOldPen);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void VLineCursor::PrepareNext() {
if (m_nPosition == 0) {
m_nStep = 1;
} else if (m_nPosition == m_nSize) {
m_nStep = -1;
}
m_nPosition += m_nStep;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// RectCursor
RectCursor::RectCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
, m_bVisible(TRUE)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 750, NULL);
}
RectCursor::~RectCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void RectCursor::Draw(LPRECT pRect) {
if (m_bActive && m_bVisible) {
::FrameRect(m_hdcWindow, pRect, m_hActiveBrush);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void RectCursor::PrepareNext() {
m_bVisible = !m_bVisible;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// NBRectCursor
NBRectCursor::NBRectCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
{
}
NBRectCursor::~NBRectCursor() {
::DeleteObject(m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void NBRectCursor::Draw(LPRECT pRect) {
::FrameRect(m_hdcWindow, pRect, m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void NBRectCursor::PrepareNext() {
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// PulseRectCursor
PulseRectCursor::PulseRectCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_hActiveBrush(::CreateSolidBrush(crCursorColor))
, m_nSize(0)
, m_nMaxSize(0)
, m_nStep(0)
{
::ZeroMemory(&m_rect, sizeof(RECT));
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 100, NULL);
}
PulseRectCursor::~PulseRectCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
::DeleteObject(m_hActiveBrush);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void PulseRectCursor::Draw(LPRECT pRect) {
// this is called only once, to set the size of the cursor
if (m_nMaxSize == 0) {
if ((pRect->right - pRect->left) < (pRect->bottom - pRect->top)) {
m_nMaxSize = (pRect->right - pRect->left) >> 1;
} else {
m_nMaxSize = (pRect->bottom - pRect->top) >> 1;
}
}
if (m_bActive) {
RECT rect;
::CopyMemory(&rect, pRect, sizeof(RECT));
rect.left += m_nSize;
rect.top += m_nSize;
rect.right -= m_nSize;
rect.bottom -= m_nSize;
::FrameRect(m_hdcWindow, &rect, m_hActiveBrush);
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void PulseRectCursor::PrepareNext() {
if (m_nSize == 0) {
m_nStep = 1;
} else if (m_nSize == m_nMaxSize) {
m_nStep = -1;
}
m_nSize += m_nStep;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// FadeBlockCursor
FadeBlockCursor::FadeBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor, COLORREF crBkColor)
: Cursor(hwndParent, hdcWindow, crCursorColor)
, m_crCursorColor(crCursorColor)
, m_nStep(1)
, m_crBkColor(crBkColor)
, m_nIndex(0)
, m_hUser32(NULL)
, m_hMemDC(NULL)
{
m_uiTimer = ::SetTimer(hwndParent, CURSOR_TIMER, 35, NULL);
#if 0
if (g_bWin2000) {
// on Win2000 we use real alpha blending
// create a reasonable-sized bitmap, since AlphaBlt resizes
// destination rect if needed, and we don't need to redraw the mem DC
// each time
m_nBmpWidth = BLEND_BMP_WIDTH;
m_nBmpHeight= BLEND_BMP_HEIGHT;
m_hMemDC = ::CreateCompatibleDC(hdcWindow);
m_hBmp = ::CreateCompatibleBitmap(hdcWindow, m_nBmpWidth, m_nBmpHeight);
m_hBmpOld = (HBITMAP)::SelectObject(m_hMemDC, m_hBmp);
HBRUSH hBrush= ::CreateSolidBrush(m_crCursorColor);
RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = m_nBmpWidth;
rect.bottom = m_nBmpHeight;
::FillRect(m_hMemDC, &rect, hBrush);
::DeleteObject(hBrush);
m_nStep = -ALPHA_STEP;
m_bfn.BlendOp = AC_SRC_OVER;
m_bfn.BlendFlags = 0;
m_bfn.SourceConstantAlpha = 255;
m_bfn.AlphaFormat = 0;
} else {
#endif
FakeBlend();
// }
}
FadeBlockCursor::~FadeBlockCursor() {
if (m_uiTimer) ::KillTimer(m_hwndParent, m_uiTimer);
#if 0
if (g_bWin2000) {
::SelectObject(m_hMemDC, m_hBmpOld);
::DeleteObject(m_hBmp);
::DeleteDC(m_hMemDC);
}
#endif
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void FadeBlockCursor::Draw(LPRECT pRect) {
#if 0
if (g_bWin2000) {
g_pfnAlphaBlend(
m_hdcWindow,
pRect->left,
pRect->top,
pRect->right - pRect->left,
pRect->bottom - pRect->top,
m_hMemDC,
0,
0,
BLEND_BMP_WIDTH,
BLEND_BMP_HEIGHT,
m_bfn);
} else {
#endif
HBRUSH hBrush = ::CreateSolidBrush(m_arrColors[m_nIndex]);
::FillRect(m_hdcWindow, pRect, hBrush);
::DeleteObject(hBrush);
// }
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void FadeBlockCursor::PrepareNext() {
#if 0
if (g_bWin2000){
if (m_bfn.SourceConstantAlpha < ALPHA_STEP) {
m_nStep = ALPHA_STEP;
} else if ((DWORD)m_bfn.SourceConstantAlpha + ALPHA_STEP > 255) {
m_nStep = -ALPHA_STEP;
}
m_bfn.SourceConstantAlpha += m_nStep;
} else {
#endif
if (m_nIndex == 0) {
m_nStep = 1;
} else if (m_nIndex == (FADE_STEPS)) {
m_nStep = -1;
}
m_nIndex += m_nStep;
// }
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// This function is used to create a fake blending for WinNT (uuseful only
// for solid background, though)
void FadeBlockCursor::FakeBlend() {
int nDeltaR = ((GetRValue(m_crCursorColor) - GetRValue(m_crBkColor)) << 8) / FADE_STEPS;
int nDeltaG = ((GetGValue(m_crCursorColor) - GetGValue(m_crBkColor)) << 8) / FADE_STEPS;
int nDeltaB = ((GetBValue(m_crCursorColor) - GetBValue(m_crBkColor)) << 8) / FADE_STEPS;
for (int i = 0; i < FADE_STEPS; ++i) {
m_arrColors[i] = RGB(GetRValue(m_crCursorColor) - (nDeltaR*i >> 8), GetGValue(m_crCursorColor) - (nDeltaG*i >> 8), GetBValue(m_crCursorColor) - (nDeltaB*i >> 8));
}
m_arrColors[FADE_STEPS] = m_crBkColor;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+345
View File
@@ -0,0 +1,345 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Cursors.h - cursor classes
#pragma once
#define CURSOR_TIMER 45
extern BOOL g_bWin2000;
/////////////////////////////////////////////////////////////////////////////
// A base class for all the cursors
class Cursor {
public:
Cursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor)
: m_hwndParent(hwndParent)
, m_hdcWindow(hdcWindow)
, m_crCursorColor(crCursorColor)
, m_bActive(TRUE)
{};
virtual ~Cursor(){};
void SetState(BOOL bActive) {m_bActive = bActive;};
BOOL GetState() { return m_bActive; }
// used to draw current frame of the cursor
virtual void Draw(LPRECT pRect) = 0;
// used to prepare the next frame of cursor animation
virtual void PrepareNext() = 0;
protected:
HWND m_hwndParent;
HDC m_hdcWindow;
COLORREF m_crCursorColor;
BOOL m_bActive;
UINT m_uiTimer;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// XTermCursor
class XTermCursor : public Cursor {
public:
XTermCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~XTermCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
HBRUSH m_hInactiveBrush;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BlockCursor
class BlockCursor : public Cursor {
public:
BlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~BlockCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
BOOL m_bVisible;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// NBBlockCursor
class NBBlockCursor : public Cursor {
public:
NBBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~NBBlockCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// PulseBlockCursor
class PulseBlockCursor : public Cursor {
public:
PulseBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~PulseBlockCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
RECT m_rect;
int m_nSize;
int m_nMaxSize;
int m_nStep;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BarCursor
class BarCursor : public Cursor {
public:
BarCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~BarCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HPEN m_hPen;
BOOL m_bVisible;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// ConsoleCursor
class ConsoleCursor : public Cursor {
public:
ConsoleCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~ConsoleCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HANDLE m_hStdOut;
HBRUSH m_hActiveBrush;
BOOL m_bVisible;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// NBHLineCursor
class NBHLineCursor : public Cursor {
public:
NBHLineCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~NBHLineCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HPEN m_hPen;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// HLineCursor
class HLineCursor : public Cursor {
public:
HLineCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~HLineCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HPEN m_hPen;
int m_nSize;
int m_nPosition;
int m_nStep;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// VLineCursor
class VLineCursor : public Cursor {
public:
VLineCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~VLineCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HPEN m_hPen;
int m_nSize;
int m_nPosition;
int m_nStep;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// RectCursor
class RectCursor : public Cursor {
public:
RectCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~RectCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
BOOL m_bVisible;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// NBRectCursor
class NBRectCursor : public Cursor {
public:
NBRectCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~NBRectCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// PulseRectCursor
class PulseRectCursor : public Cursor {
public:
PulseRectCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor);
~PulseRectCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
HBRUSH m_hActiveBrush;
RECT m_rect;
int m_nSize;
int m_nMaxSize;
int m_nStep;
};
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// FadeBlockCursor
#define FADE_STEPS 20
#define ALPHA_STEP 12
#define BLEND_BMP_WIDTH 10
#define BLEND_BMP_HEIGHT 20
class FadeBlockCursor : public Cursor {
public:
FadeBlockCursor(HWND hwndParent, HDC hdcWindow, COLORREF crCursorColor, COLORREF crBkColor);
~FadeBlockCursor();
void Draw(LPRECT pRect);
void PrepareNext();
private:
void FakeBlend();
COLORREF m_crCursorColor;
int m_nStep;
// used under WinNT 4.0
COLORREF m_crBkColor;
COLORREF m_arrColors[FADE_STEPS+1];
int m_nIndex;
// these are used under Win2000 only
HMODULE m_hUser32;
BLENDFUNCTION m_bfn;
HDC m_hMemDC;
HBITMAP m_hBmp;
HBITMAP m_hBmpOld;
int m_nBmpWidth;
int m_nBmpHeight;
};
/////////////////////////////////////////////////////////////////////////////
+133
View File
@@ -0,0 +1,133 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Dialogs.h - dialog classes
//
// About dialog class, etc...
//#include "stdafx.h"
#include <Windows.h>
#include "resource.h"
#include "Console.h"
#include "Dialogs.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern HINSTANCE ghInstance;
/////////////////////////////////////////////////////////////////////////////
// About dialog class
/////////////////////////////////////////////////////////////////////////////
// Ctor/Dtor
CAboutDlg::CAboutDlg(HWND hwndParent)
: m_hWndParent(hwndParent)
{
}
CAboutDlg::~CAboutDlg()
{
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// public methods
/////////////////////////////////////////////////////////////////////////////
// DoModal - shows About dialog
BOOL CAboutDlg::DoModal()
{
::DialogBox(
ghInstance,
MAKEINTRESOURCE(IDD_ABOUT),
m_hWndParent,
CAboutDlg::DialogProc);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// message handlers
/////////////////////////////////////////////////////////////////////////////
// DialogProc - dialog window procedure
int CALLBACK CAboutDlg::DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
if (HIWORD(wParam) == BN_CLICKED) {
::EndDialog(hwndDlg, MB_OK);
return TRUE;
}
break;
}
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
+64
View File
@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Dialogs.h - dialog classes
//
// About dialog class, etc...
#pragma once
/////////////////////////////////////////////////////////////////////////////
// About dialog class
class CAboutDlg {
public:
CAboutDlg(HWND hwndParent);
~CAboutDlg();
// public methods
public:
// shows About dialog
BOOL DoModal();
// public data
public:
// parent window handle
HWND m_hWndParent;
// private methods
private:
/////////////////////////
// message handlers
// dialog window procedure
static int CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
// private data
private:
};
/////////////////////////////////////////////////////////////////////////////
+259
View File
@@ -0,0 +1,259 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// FileStream.cpp - implementation of IStream interface on any file
// (not strictly COM, I'm faking it here a bit :-)
//
#undef CINTERFACE
#include "builddefines.h"
//#include "stdafx.h"
//#include <atlbase.h>
#include <Windows.h>
#include <objidl.h>
#include "FileStream.h"
//#ifdef _DEBUG
//#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
//#endif
/////////////////////////////////////////////////////////////////////////////
// CreateFileStream - opens/creates a file and returns an IStream interface
HRESULT CreateFileStream(
LPCTSTR lpFileName, // file name
DWORD dwDesiredAccess, // access mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile, // handle to template file
IStream** ppStream // pointer to IStream interface
)
{
HANDLE hFile = ::CreateFile(
lpFileName,
dwDesiredAccess,
dwShareMode,
lpSecurityAttributes,
dwCreationDisposition,
dwFlagsAndAttributes,
hTemplateFile);
if (hFile == INVALID_HANDLE_VALUE) {
DWORD a = ::GetLastError();
ppStream = NULL;
return E_FAIL;
}
FileStream* pFileStream = new FileStream(hFile);
return pFileStream->QueryInterface(IID_IStream, (void**)ppStream);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// FileStream class
/////////////////////////////////////////////////////////////////////////////
// ctor/dtor
FileStream::FileStream(HANDLE hFile)
: m_lRefCount(0)
, m_hFile(hFile)
{
}
FileStream::~FileStream()
{
if (m_hFile) ::CloseHandle(m_hFile);
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// IStream methods
/////////////////////////////////////////////////////////////////////////////
// Read - reads a specified number of bytes from the stream object into memory
// starting at the current seek pointer
STDMETHODIMP FileStream::Read(void *pv, ULONG cb, ULONG *pcbRead)
{
if (!::ReadFile(m_hFile, pv, cb, pcbRead, NULL)) return S_FALSE;
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Write - writes a specified number of bytes into the stream object starting
// at the current seek pointer
STDMETHODIMP FileStream::Write(void const *pv, ULONG cb, ULONG *pcbWritten)
{
if (!::WriteFile(m_hFile, pv, cb, pcbWritten, NULL)) return S_FALSE;
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Seek - changes the seek pointer to a new location relative to the beginning
// of the stream, to the end of the stream, or to the current seek pointer
STDMETHODIMP FileStream::Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
DWORD dwFileOrigin;
DWORD dwMoveLow = dlibMove.LowPart;
LONG lMoveHigh = dlibMove.HighPart;
switch (dwOrigin) {
case STREAM_SEEK_SET : dwFileOrigin = FILE_BEGIN; break;
case STREAM_SEEK_CUR : dwFileOrigin = FILE_CURRENT; break;
case STREAM_SEEK_END : dwFileOrigin = FILE_END; break;
default:dwFileOrigin = FILE_BEGIN;
}
DWORD dwRet = ::SetFilePointer(m_hFile, dwMoveLow, &lMoveHigh, dwFileOrigin);
if (::GetLastError() != NO_ERROR) return STG_E_INVALIDPOINTER;
plibNewPosition->LowPart = dwRet;
plibNewPosition->HighPart = lMoveHigh;
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// SetSize - not really doing anything here
STDMETHODIMP FileStream::SetSize(ULARGE_INTEGER libNewSize)
{
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// CopyTo - copies a specified number of bytes from the current seek pointer
// in the stream to the current seek pointer in another stream
STDMETHODIMP FileStream::CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
{
// later...
return E_NOTIMPL;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Commit - no work here...
STDMETHODIMP FileStream::Commit(DWORD grfCommitFlags)
{
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Revert - no work here...
STDMETHODIMP FileStream::Revert(void)
{
return S_OK;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// LockRegion - no work here...
STDMETHODIMP FileStream::LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
{
return E_NOTIMPL;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// UnlockRegion - no work here...
STDMETHODIMP FileStream::UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
{
return E_NOTIMPL;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Stat - no work here...
STDMETHODIMP FileStream::Stat(STATSTG *pstatstg, DWORD grfStatFlag)
{
return E_NOTIMPL;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Clone - no work here...
STDMETHODIMP FileStream::Clone(IStream **ppstm)
{
return E_NOTIMPL;
}
/////////////////////////////////////////////////////////////////////////////
+107
View File
@@ -0,0 +1,107 @@
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2001-2004 by Marko Bozikovic
// All rights reserved
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date. I can be reached as follows:
// marko.bozikovic@alterbox.net
// bozho@kset.org
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// FileStream.h - implementation of IStream interface on any file
// (not really COM, I'm faking it here a bit :-)
//
#pragma once
/////////////////////////////////////////////////////////////////////////////
// CreateFileStream - opens/creates a file and returns an IStream interface
HRESULT CreateFileStream(
LPCTSTR lpFileName, // file name
DWORD dwDesiredAccess, // access mode
DWORD dwShareMode, // share mode
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
DWORD dwCreationDisposition, // how to create
DWORD dwFlagsAndAttributes, // file attributes
HANDLE hTemplateFile, // handle to template file
IStream** ppStream // pointer to IStream interface
);
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// FileStream class
class FileStream : public IStream {
public:
FileStream(HANDLE hFile);
~FileStream();
// IUnknown methods
STDMETHOD(QueryInterface)(REFIID riid, void ** ppv) {
if (riid == IID_IUnknown) {
*ppv = static_cast<IStream*>(this);
} else if (riid == IID_IStream) {
*ppv = static_cast<IStream*>(this);
} else {
*ppv = NULL;
return E_NOINTERFACE;
}
static_cast<IUnknown*>(*ppv)->AddRef();
return S_OK;
};
STDMETHOD_(ULONG, AddRef)(void) {
return ::InterlockedIncrement(&m_lRefCount);
};
STDMETHOD_(ULONG, Release)(void) {
long l = ::InterlockedDecrement(&m_lRefCount);
if (l == 0) delete this;
return l;
};
// IStream methods
STDMETHOD(Read)(void *pv, ULONG cb, ULONG *pcbRead);
STDMETHOD(Write)(void const *pv, ULONG cb, ULONG *pcbWritten);
STDMETHOD(Seek)(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
STDMETHOD(SetSize)(ULARGE_INTEGER libNewSize);
STDMETHOD(CopyTo)(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
STDMETHOD(Commit)(DWORD grfCommitFlags);
STDMETHOD(Revert)(void);
STDMETHOD(LockRegion)(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
STDMETHOD(UnlockRegion)(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
STDMETHOD(Stat)(STATSTG *pstatstg, DWORD grfStatFlag);
STDMETHOD(Clone)(IStream **ppstm);
private: // private data
// reference count
long m_lRefCount;
// file handle
HANDLE m_hFile;
};
/////////////////////////////////////////////////////////////////////////////
+1200
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+2 -2
View File
@@ -912,8 +912,8 @@ BOOLEAN CheckIfGameCdromIsInCDromDrive()
// ATE: These are ness. due to reference counting // ATE: These are ness. due to reference counting
// in showcursor(). I'm not about to go digging in low level stuff at this // in showcursor(). I'm not about to go digging in low level stuff at this
// point in the game development, so keep these here, as this works... // point in the game development, so keep these here, as this works...
ShowCursor(TRUE); // ShowCursor(TRUE);
ShowCursor(TRUE); // ShowCursor(TRUE);
ShutdownWithErrorBox( sString ); ShutdownWithErrorBox( sString );
//DoTester( ); //DoTester( );
+1
View File
@@ -988,6 +988,7 @@ void GetHelpScreenUserInput()
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( DequeueEvent( &Event ) ) while( DequeueEvent( &Event ) )
{ {
+2 -2
View File
@@ -712,8 +712,8 @@ void HandleLaserLockResult( BOOLEAN fSuccess )
sprintf( zString, "%S", gzLateLocalizedString[56] ); sprintf( zString, "%S", gzLateLocalizedString[56] );
ShowCursor(TRUE); // ShowCursor(TRUE);
ShowCursor(TRUE); // ShowCursor(TRUE);
ShutdownWithErrorBox( zString ); ShutdownWithErrorBox( zString );
} }
} }
+1
View File
@@ -276,6 +276,7 @@ void GetIntroScreenUserInput()
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( DequeueEvent( &Event ) ) while( DequeueEvent( &Event ) )
{ {
+2 -1
View File
@@ -468,7 +468,8 @@ void GetPlayerKeyBoardInputForIMPBeginScreen( void )
// get the current curosr position, might just need it. // get the current curosr position, might just need it.
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
// handle input events // handle input events
while( DequeueEvent(&InputEvent) ) while( DequeueEvent(&InputEvent) )
{ {
+1
View File
@@ -259,6 +259,7 @@ void GetPlayerKeyBoardInputForIMPHomePage( void )
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while (DequeueEvent(&InputEvent) == TRUE) while (DequeueEvent(&InputEvent) == TRUE)
{ {
+1
View File
@@ -1613,6 +1613,7 @@ void HandleIMPQuizKeyBoard( void )
BOOLEAN fSkipFrame = FALSE; BOOLEAN fSkipFrame = FALSE;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( ( DequeueEvent(&InputEvent) == TRUE ) ) while( ( DequeueEvent(&InputEvent) == TRUE ) )
{ {
+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+2
View File
@@ -690,6 +690,7 @@ GetLaptopKeyboardInput()
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
fTabHandled = FALSE; fTabHandled = FALSE;
@@ -3188,6 +3189,7 @@ CheckIfMouseLeaveScreen()
{ {
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
if((MousePos.x >LAPTOP_SCREEN_LR_X )||(MousePos.x<LAPTOP_UL_X)||(MousePos.y<LAPTOP_UL_Y )||(MousePos.y >LAPTOP_SCREEN_LR_Y)) if((MousePos.x >LAPTOP_SCREEN_LR_X )||(MousePos.x<LAPTOP_UL_X)||(MousePos.y<LAPTOP_UL_Y )||(MousePos.y >LAPTOP_SCREEN_LR_Y))
{ {
guiCurrentLapTopCursor=LAPTOP_PANEL_CURSOR; guiCurrentLapTopCursor=LAPTOP_PANEL_CURSOR;
+2
View File
@@ -5883,6 +5883,7 @@ void HandleSliderBarClickCallback( MOUSE_REGION *pRegion, INT32 iReason )
// find the x,y on the slider bar // find the x,y on the slider bar
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
// get the subregion sizes // get the subregion sizes
sSizeOfEachSubRegion = ( INT16 )( ( INT32 )( Y_SIZE_OF_PERSONNEL_SCROLL_REGION - SIZE_OF_PERSONNEL_CURSOR ) / ( INT32 )( iNumberOfItems ) ); sSizeOfEachSubRegion = ( INT16 )( ( INT32 )( Y_SIZE_OF_PERSONNEL_SCROLL_REGION - SIZE_OF_PERSONNEL_CURSOR ) / ( INT32 )( iNumberOfItems ) );
@@ -6736,6 +6737,7 @@ void HandlePersonnelKeyboard( void )
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while (DequeueEvent(&InputEvent) == TRUE) while (DequeueEvent(&InputEvent) == TRUE)
{ {
+1
View File
@@ -792,6 +792,7 @@ void GetOptionsScreenUserInput()
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( DequeueEvent( &Event ) ) while( DequeueEvent( &Event ) )
{ {
+7 -2
View File
@@ -3,6 +3,7 @@
// Used by ja2.rc // Used by ja2.rc
// //
#define IDI_ICON1 113 #define IDI_ICON1 113
#define IDI_ICON2 115
// Next default values for new objects // Next default values for new objects
// //
@@ -16,8 +17,12 @@
#endif #endif
#define ID_ABOUT 116
#define IDD_ABOUT 117
#define ID_COPY 118
#define ID_PASTE 119
#define ID_EXIT_CONSOLE 120
#define IDR_POPUP_MENU 130
+6
View File
@@ -2726,6 +2726,9 @@ BOOLEAN LoadSavedGame( UINT8 ubSavedGameID )
if ( (gTacticalStatus.uiFlags & INCOMBAT) ) if ( (gTacticalStatus.uiFlags & INCOMBAT) )
{ {
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Setting attack busy count to 0 from load" ) ); DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Setting attack busy count to 0 from load" ) );
#ifdef DEBUG_ATTACKBUSY
OutputDebugString( "Resetting attack busy due to load game.\n");
#endif
gTacticalStatus.ubAttackBusyCount = 0; gTacticalStatus.ubAttackBusyCount = 0;
} }
@@ -2850,6 +2853,9 @@ BOOLEAN LoadSavedGame( UINT8 ubSavedGameID )
// fix lingering attack busy count problem on loading saved game by resetting a.b.c // fix lingering attack busy count problem on loading saved game by resetting a.b.c
// if we're not in combat. // if we're not in combat.
gTacticalStatus.ubAttackBusyCount = 0; gTacticalStatus.ubAttackBusyCount = 0;
#ifdef DEBUG_ATTACKBUSY
OutputDebugString( "Resetting attack busy due to game load.\n");
#endif
} }
// fix squads // fix squads
+1
View File
@@ -845,6 +845,7 @@ void GetSaveLoadScreenUserInput()
static BOOLEAN fWasCtrlHeldDownLastFrame = FALSE; static BOOLEAN fWasCtrlHeldDownLastFrame = FALSE;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
//if we are going to be instantly leaving the screen, dont draw the numbers //if we are going to be instantly leaving the screen, dont draw the numbers
if( gfLoadGameUponEntry ) if( gfLoadGameUponEntry )
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+46 -17
View File
@@ -67,8 +67,8 @@ UINT32 guiRightButtonRepeatTimer;
BOOLEAN gfTrackMousePos; // TRUE = queue mouse movement events, FALSE = don't BOOLEAN gfTrackMousePos; // TRUE = queue mouse movement events, FALSE = don't
BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed
BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed
UINT16 gusMouseXPos; // X position of the mouse on screen INT16 gusMouseXPos; // X position of the mouse on screen
UINT16 gusMouseYPos; // y position of the mouse on screen INT16 gusMouseYPos; // y position of the mouse on screen
// The queue structures are used to track input events using queued events // The queue structures are used to track input events using queued events
@@ -120,7 +120,7 @@ LRESULT CALLBACK KeyboardHandler(int Code, WPARAM wParam, LPARAM lParam)
else else
{ // Key was up { // Key was up
KeyDown(wParam, lParam); KeyDown(wParam, lParam);
gfSGPInputReceived = TRUE; gfSGPInputReceived = TRUE;
} }
return TRUE; return TRUE;
@@ -131,6 +131,7 @@ LRESULT CALLBACK KeyboardHandler(int Code, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
{ {
UINT32 uiParam; UINT32 uiParam;
POINT mpos;
#ifndef JA2 #ifndef JA2
if((Code < 0) || (!gfApplicationActive)) if((Code < 0) || (!gfApplicationActive))
@@ -145,8 +146,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
{ {
case WM_LBUTTONDOWN case WM_LBUTTONDOWN
: // Update the current mouse position : // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x; mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y; ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos; uiParam = gusMouseYPos;
uiParam = uiParam << 16; uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos; uiParam = uiParam | gusMouseXPos;
@@ -159,8 +162,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break; break;
case WM_LBUTTONUP case WM_LBUTTONUP
: // Update the current mouse position : // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x; mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y; ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos; uiParam = gusMouseYPos;
uiParam = uiParam << 16; uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos; uiParam = uiParam | gusMouseXPos;
@@ -173,8 +178,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break; break;
case WM_RBUTTONDOWN case WM_RBUTTONDOWN
: // Update the current mouse position : // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x; mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y; ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos; uiParam = gusMouseYPos;
uiParam = uiParam << 16; uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos; uiParam = uiParam | gusMouseXPos;
@@ -187,8 +194,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break; break;
case WM_RBUTTONUP case WM_RBUTTONUP
: // Update the current mouse position : // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x; mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y; ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos; uiParam = gusMouseYPos;
uiParam = uiParam << 16; uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos; uiParam = uiParam | gusMouseXPos;
@@ -201,8 +210,10 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
break; break;
case WM_MOUSEMOVE case WM_MOUSEMOVE
: // Update the current mouse position : // Update the current mouse position
gusMouseXPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).x; mpos = ((MOUSEHOOKSTRUCT *)lParam)->pt;
gusMouseYPos = (UINT16)(((MOUSEHOOKSTRUCT *)lParam)->pt).y; ScreenToClient( ghWindow, &mpos);
gusMouseXPos = (INT16)mpos.x;
gusMouseYPos = (INT16)mpos.y;
uiParam = gusMouseYPos; uiParam = gusMouseYPos;
uiParam = uiParam << 16; uiParam = uiParam << 16;
uiParam = uiParam | gusMouseXPos; uiParam = uiParam | gusMouseXPos;
@@ -214,7 +225,16 @@ LRESULT CALLBACK MouseHandler(int Code, WPARAM wParam, LPARAM lParam)
//Set that we have input //Set that we have input
gfSGPInputReceived = TRUE; gfSGPInputReceived = TRUE;
break; break;
default:
return CallNextHookEx(ghMouseHook, Code, wParam, lParam);
} }
// if (gusMouseXPos < 0 || gusMouseXPos >= SCREEN_WIDTH ||
// gusMouseYPos < 0 || gusMouseYPos >= SCREEN_HEIGHT)
{
return CallNextHookEx(ghMouseHook, Code, wParam, lParam);
}
return TRUE; return TRUE;
} }
@@ -346,8 +366,8 @@ BOOLEAN InitializeInputManager(void)
gfCurrentStringInputState = FALSE; gfCurrentStringInputState = FALSE;
gpCurrentStringDescriptor = NULL; gpCurrentStringDescriptor = NULL;
// Activate the hook functions for both keyboard and Mouse // Activate the hook functions for both keyboard and Mouse
ghKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardHandler, (HINSTANCE) 0, GetCurrentThreadId()); // ghKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) KeyboardHandler, (HINSTANCE) 0, GetCurrentThreadId());
DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set keyboard hook returned %d", ghKeyboardHook)); // DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set keyboard hook returned %d", ghKeyboardHook));
ghMouseHook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC) MouseHandler, (HINSTANCE) 0, GetCurrentThreadId()); ghMouseHook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC) MouseHandler, (HINSTANCE) 0, GetCurrentThreadId());
DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set mouse hook returned %d", ghMouseHook)); DbgMessage(TOPIC_INPUT, DBG_LEVEL_2, String("Set mouse hook returned %d", ghMouseHook));
@@ -358,7 +378,7 @@ void ShutdownInputManager(void)
{ // There's very little to do when shutting down the input manager. In the future, this is where the keyboard and { // There's very little to do when shutting down the input manager. In the future, this is where the keyboard and
// mouse hooks will be destroyed // mouse hooks will be destroyed
UnRegisterDebugTopic(TOPIC_INPUT, "Input Manager"); UnRegisterDebugTopic(TOPIC_INPUT, "Input Manager");
UnhookWindowsHookEx(ghKeyboardHook); // UnhookWindowsHookEx(ghKeyboardHook);
UnhookWindowsHookEx(ghMouseHook); UnhookWindowsHookEx(ghMouseHook);
} }
@@ -913,6 +933,8 @@ void KeyChange(UINT32 usParam, UINT32 uiParam, UINT8 ufKeyState)
} }
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff); uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff);
if (ufKeyState == TRUE) if (ufKeyState == TRUE)
@@ -1064,6 +1086,7 @@ void GetMousePos(SGPPoint *Point)
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
Point->iX = (UINT32) MousePos.x; Point->iX = (UINT32) MousePos.x;
Point->iY = (UINT32) MousePos.y; Point->iY = (UINT32) MousePos.y;
@@ -1517,7 +1540,9 @@ void RestrictMouseCursor(SGPRect *pRectangle)
{ {
// Make a copy of our rect.... // Make a copy of our rect....
memcpy( &gCursorClipRect, pRectangle, sizeof( gCursorClipRect ) ); memcpy( &gCursorClipRect, pRectangle, sizeof( gCursorClipRect ) );
ClipCursor((RECT *)pRectangle); ClientToScreen( ghWindow, (LPPOINT)&gCursorClipRect);
ClientToScreen( ghWindow, ((LPPOINT)&gCursorClipRect)+1);
ClipCursor(&gCursorClipRect);
fCursorWasClipped = TRUE; fCursorWasClipped = TRUE;
} }
@@ -1538,6 +1563,8 @@ void RestoreCursorClipRect( void )
void GetRestrictedClipCursor( SGPRect *pRectangle ) void GetRestrictedClipCursor( SGPRect *pRectangle )
{ {
GetClipCursor((RECT *) pRectangle ); GetClipCursor((RECT *) pRectangle );
ScreenToClient( ghWindow, (LPPOINT)pRectangle);
ScreenToClient( ghWindow, ((LPPOINT)pRectangle)+1);
} }
BOOLEAN IsCursorRestricted( void ) BOOLEAN IsCursorRestricted( void )
@@ -1613,6 +1640,7 @@ void HandleSingleClicksAndButtonRepeats( void )
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff); uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff);
QueueEvent(LEFT_BUTTON_REPEAT, 0, uiTmpLParam); QueueEvent(LEFT_BUTTON_REPEAT, 0, uiTmpLParam);
guiLeftButtonRepeatTimer = uiTimer + BUTTON_REPEAT_TIME; guiLeftButtonRepeatTimer = uiTimer + BUTTON_REPEAT_TIME;
@@ -1633,6 +1661,7 @@ void HandleSingleClicksAndButtonRepeats( void )
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff); uiTmpLParam = ((MousePos.y << 16) & 0xffff0000) | (MousePos.x & 0x0000ffff);
QueueEvent(RIGHT_BUTTON_REPEAT, 0, uiTmpLParam); QueueEvent(RIGHT_BUTTON_REPEAT, 0, uiTmpLParam);
guiRightButtonRepeatTimer = uiTimer + BUTTON_REPEAT_TIME; guiRightButtonRepeatTimer = uiTimer + BUTTON_REPEAT_TIME;
+2 -2
View File
@@ -107,8 +107,8 @@ extern void DequeueAllKeyBoardEvents();
extern BOOLEAN gfKeyState[256]; // TRUE = Pressed, FALSE = Not Pressed extern BOOLEAN gfKeyState[256]; // TRUE = Pressed, FALSE = Not Pressed
extern UINT16 gusMouseXPos; // X position of the mouse on screen extern INT16 gusMouseXPos; // X position of the mouse on screen
extern UINT16 gusMouseYPos; // y position of the mouse on screen extern INT16 gusMouseYPos; // y position of the mouse on screen
extern BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed extern BOOLEAN gfLeftButtonState; // TRUE = Pressed, FALSE = Not Pressed
extern BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed extern BOOLEAN gfRightButtonState; // TRUE = Pressed, FALSE = Not Pressed
+1 -1
View File
@@ -555,7 +555,7 @@ void MSYS_DeleteRegionFromList(MOUSE_REGION *region)
//====================================================================================================== //======================================================================================================
// MSYS_UpdateMouseRegion // MSYS_UpdateMouseRegion
// //
// Searches the list for the highest priority region and updates it's info. It also dispatches // Searches the list for the highest priority region and updates its info. It also dispatches
// the callback functions // the callback functions
// //
void MSYS_UpdateMouseRegion(void) void MSYS_UpdateMouseRegion(void)
+67 -9
View File
@@ -73,6 +73,7 @@ void GetRuntimeSettings( );
int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCommandLine, int sCommandShow); int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCommandLine, int sCommandShow);
Console g_Console("", "", "Lua Console", "no");
#if !defined(JA2) && !defined(UTILS) #if !defined(JA2) && !defined(UTILS)
void ProcessCommandLine(CHAR8 *pCommandLine); void ProcessCommandLine(CHAR8 *pCommandLine);
@@ -95,6 +96,7 @@ HINSTANCE ghInstance;
// Global Variable Declarations // Global Variable Declarations
RECT rcWindow; RECT rcWindow;
POINT ptWindowSize;
// moved from header file: 24mar98:HJH // moved from header file: 24mar98:HJH
UINT32 giStartMem; UINT32 giStartMem;
@@ -141,6 +143,10 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
switch(Message) switch(Message)
{ {
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
{ {
QueueEvent(MOUSE_WHEEL, wParam, lParam); QueueEvent(MOUSE_WHEEL, wParam, lParam);
@@ -149,13 +155,22 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
#ifdef JA2 #ifdef JA2
case WM_MOVE: case WM_MOVE:
if( 1==iScreenMode ) // if( 1==iScreenMode )
{ // {
GetClientRect(hWindow, &rcWindow); GetClientRect(hWindow, &rcWindow);
ClientToScreen(hWindow, (LPPOINT)&rcWindow); ClientToScreen(hWindow, (LPPOINT)&rcWindow);
ClientToScreen(hWindow, (LPPOINT)&rcWindow+1); ClientToScreen(hWindow, (LPPOINT)&rcWindow+1);
} // }
break; break;
case WM_GETMINMAXINFO:
{
MINMAXINFO *mmi = (MINMAXINFO*)lParam;
mmi->ptMaxSize = ptWindowSize;
mmi->ptMaxTrackSize = mmi->ptMaxSize;
mmi->ptMinTrackSize = mmi->ptMaxSize;
break;
}
#else #else
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
break; break;
@@ -303,6 +318,20 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
} }
break; break;
#endif #endif
case WM_SETCURSOR:
SetCursor( NULL);
return TRUE;
case WM_TIMER:
#ifdef LUACONSOLE
PollConsole( );
#endif
if (gfApplicationActive)
{
GameLoop();
}
break;
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
switch(wParam) switch(wParam)
@@ -360,7 +389,7 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
case WM_DESTROY: case WM_DESTROY:
ShutdownStandardGamingPlatform(); ShutdownStandardGamingPlatform();
ShowCursor(TRUE); // ShowCursor(TRUE);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
@@ -410,6 +439,24 @@ INT32 FAR PASCAL WindowProcedure(HWND hWindow, UINT16 Message, WPARAM wParam, LP
break; break;
#endif #endif
case WM_SYSKEYUP:
case WM_KEYUP:
KeyUp(wParam, lParam);
break;
case WM_SYSKEYDOWN:
case WM_KEYDOWN:
KeyDown(wParam, lParam);
gfSGPInputReceived = TRUE;
break;
case WM_CHAR:
if (wParam == '\\' &&
lParam && KF_ALTDOWN)
{
g_Console.Create(NULL);
}
break;
default default
: return DefWindowProc(hWindow, Message, wParam, lParam); : return DefWindowProc(hWindow, Message, wParam, lParam);
} }
@@ -701,6 +748,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
#endif #endif
MSG Message; MSG Message;
HWND hPrevInstanceWindow; HWND hPrevInstanceWindow;
UINT32 uiTimer = 0;
// Make sure that only one instance of this application is running at once // Make sure that only one instance of this application is running at once
// // Look for prev instance by searching for the window // // Look for prev instance by searching for the window
@@ -753,7 +801,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
#endif #endif
ShowCursor(FALSE); // ShowCursor(FALSE);
// Inititialize the SGP // Inititialize the SGP
if (InitializeStandardGamingPlatform(hInstance, sCommandShow) == FALSE) if (InitializeStandardGamingPlatform(hInstance, sCommandShow) == FALSE)
@@ -762,7 +810,10 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
} }
#ifdef LUACONSOLE #ifdef LUACONSOLE
CreateConsole(); if (1==iScreenMode)
{
CreateConsole();
}
#endif #endif
#ifdef JA2 #ifdef JA2
@@ -776,12 +827,15 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
FastDebugMsg("Running Game"); FastDebugMsg("Running Game");
// 0verhaul: Roughly 60 frames per second. The original "low cpu" code did 30, but that is really slow
SetTimer( ghWindow, uiTimer, 16, NULL);
// At this point the SGP is set up, which means all I/O, Memory, tools, etc... are available. All we need to do is // At this point the SGP is set up, which means all I/O, Memory, tools, etc... are available. All we need to do is
// attend to the gaming mechanics themselves // attend to the gaming mechanics themselves
while (gfProgramIsRunning) while (gfProgramIsRunning)
{ {
if (PeekMessage(&Message, NULL, 0, 0, PM_NOREMOVE)) // if (PeekMessage(&Message, NULL, 0, 0, PM_NOREMOVE))
{ // We have a message on the WIN95 queue, let's get it // { // We have a message on the WIN95 queue, let's get it
if (!GetMessage(&Message, NULL, 0, 0)) if (!GetMessage(&Message, NULL, 0, 0))
{ // It's quitting time { // It's quitting time
return Message.wParam; return Message.wParam;
@@ -790,6 +844,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
TranslateMessage(&Message); TranslateMessage(&Message);
DispatchMessage(&Message); DispatchMessage(&Message);
} }
#if 0
else else
{ // Windows hasn't processed any messages, therefore we handle the rest { // Windows hasn't processed any messages, therefore we handle the rest
#ifdef LUACONSOLE #ifdef LUACONSOLE
@@ -809,6 +864,9 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR p
} }
} }
} }
#endif
KillTimer( ghWindow, uiTimer);
// This is the normal exit point // This is the normal exit point
FastDebugMsg("Exiting Game"); FastDebugMsg("Exiting Game");
@@ -854,7 +912,7 @@ void SGPExit(void)
#endif #endif
ShutdownStandardGamingPlatform(); ShutdownStandardGamingPlatform();
ShowCursor(TRUE); // ShowCursor(TRUE);
if(strlen(gzErrorMsg)) if(strlen(gzErrorMsg))
{ {
MessageBox(NULL, gzErrorMsg, "Error", MB_OK | MB_ICONERROR ); MessageBox(NULL, gzErrorMsg, "Error", MB_OK | MB_ICONERROR );
+186 -108
View File
@@ -58,8 +58,8 @@ extern int iScreenMode;
typedef struct typedef struct
{ {
BOOLEAN fRestore; BOOLEAN fRestore;
UINT16 usMouseXPos, usMouseYPos; INT16 usMouseXPos, usMouseYPos;
UINT16 usLeft, usTop, usRight, usBottom; INT16 usLeft, usTop, usRight, usBottom;
RECT Region; RECT Region;
LPDIRECTDRAWSURFACE _pSurface; LPDIRECTDRAWSURFACE _pSurface;
LPDIRECTDRAWSURFACE2 pSurface; LPDIRECTDRAWSURFACE2 pSurface;
@@ -109,7 +109,7 @@ static LPDIRECTDRAWSURFACE _gpFrameBuffer = NULL;
static LPDIRECTDRAWSURFACE2 gpFrameBuffer = NULL; static LPDIRECTDRAWSURFACE2 gpFrameBuffer = NULL;
static LPDIRECTDRAWSURFACE _gpBackBuffer = NULL; static LPDIRECTDRAWSURFACE _gpBackBuffer = NULL;
extern RECT rcWindow; extern RECT rcWindow;
extern POINT ptWindowSize;
// //
@@ -252,7 +252,29 @@ BOOLEAN InitializeVideoManager(HINSTANCE hInstance, UINT16 usCommandShow, void *
// Don't change this // Don't change this
// //
if( 1==iScreenMode ) if( 1==iScreenMode )
hWindow = CreateWindowEx(0, (LPCSTR) ClassName, "Windowed JA2 !!", WS_POPUP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, NULL, NULL, hInstance, NULL); {
RECT window;
DWORD style;
DWORD exstyle;
window.top = 0;
window.left = 0;
window.right = SCREEN_WIDTH;
window.bottom = SCREEN_HEIGHT;
exstyle = WS_EX_APPWINDOW;
style = WS_OVERLAPPEDWINDOW & (~(WS_MAXIMIZEBOX | WS_SYSMENU));
AdjustWindowRectEx( &window, style, FALSE, exstyle);
OffsetRect( &window, -window.left, -window.top);
ptWindowSize.x = window.right;
ptWindowSize.y = window.bottom;
hWindow = CreateWindowEx(exstyle, (LPCSTR) ClassName, "Windowed JA2 !!", style, window.left, window.top, window.right, window.bottom, NULL, NULL, hInstance, NULL);
GetClientRect( hWindow, &window);
window.top = window.top;
}
else else
hWindow = CreateWindowEx(WS_EX_TOPMOST, (LPCSTR) ClassName, (LPCSTR)ClassName, WS_POPUP | WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); hWindow = CreateWindowEx(WS_EX_TOPMOST, (LPCSTR) ClassName, (LPCSTR)ClassName, WS_POPUP | WS_VISIBLE, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL);
@@ -275,7 +297,7 @@ BOOLEAN InitializeVideoManager(HINSTANCE hInstance, UINT16 usCommandShow, void *
// Display our full screen window // Display our full screen window
// //
ShowCursor(FALSE); // ShowCursor(FALSE);
ShowWindow(hWindow, usCommandShow); ShowWindow(hWindow, usCommandShow);
UpdateWindow(hWindow); UpdateWindow(hWindow);
SetFocus(hWindow); SetFocus(hWindow);
@@ -348,6 +370,8 @@ BOOLEAN InitializeVideoManager(HINSTANCE hInstance, UINT16 usCommandShow, void *
ZEROMEM(SurfaceDescription); ZEROMEM(SurfaceDescription);
if( 1==iScreenMode ) /* Windowed mode */ if( 1==iScreenMode ) /* Windowed mode */
{ {
LPDIRECTDRAWCLIPPER clip;
// Create a primary surface and a backbuffer in system memory // Create a primary surface and a backbuffer in system memory
SurfaceDescription.dwSize = sizeof(DDSURFACEDESC); SurfaceDescription.dwSize = sizeof(DDSURFACEDESC);
SurfaceDescription.dwFlags = DDSD_CAPS; SurfaceDescription.dwFlags = DDSD_CAPS;
@@ -360,6 +384,26 @@ BOOLEAN InitializeVideoManager(HINSTANCE hInstance, UINT16 usCommandShow, void *
return FALSE; return FALSE;
} }
ReturnCode = DirectDrawCreateClipper ( 0, &clip, NULL );
if (ReturnCode != DD_OK)
{
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
return FALSE;
}
ReturnCode = IDirectDrawClipper_SetHWnd( clip, 0, ghWindow);
if (ReturnCode != DD_OK)
{
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
return FALSE;
}
ReturnCode = IDirectDrawSurface_SetClipper( _gpPrimarySurface, clip);
if (ReturnCode != DD_OK)
{
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
return FALSE;
}
ReturnCode = IDirectDrawSurface_QueryInterface(_gpPrimarySurface, /*&*/IID_IDirectDrawSurface2, (LPVOID *)&gpPrimarySurface); // (jonathanl) ReturnCode = IDirectDrawSurface_QueryInterface(_gpPrimarySurface, /*&*/IID_IDirectDrawSurface2, (LPVOID *)&gpPrimarySurface); // (jonathanl)
if (ReturnCode != DD_OK) if (ReturnCode != DD_OK)
@@ -647,7 +691,7 @@ void DoTester( )
{ {
IDirectDraw2_RestoreDisplayMode( gpDirectDrawObject ); IDirectDraw2_RestoreDisplayMode( gpDirectDrawObject );
IDirectDraw2_SetCooperativeLevel(gpDirectDrawObject, ghWindow, DDSCL_NORMAL ); IDirectDraw2_SetCooperativeLevel(gpDirectDrawObject, ghWindow, DDSCL_NORMAL );
ShowCursor(TRUE); // ShowCursor(TRUE);
} }
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -997,6 +1041,9 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
GetCurrentVideoSettings( &usWidth, &usHeight, &ubBitDepth ); GetCurrentVideoSettings( &usWidth, &usHeight, &ubBitDepth );
usHeight=(gsVIEWPORT_WINDOW_END_Y - gsVIEWPORT_WINDOW_START_Y ); usHeight=(gsVIEWPORT_WINDOW_END_Y - gsVIEWPORT_WINDOW_START_Y );
pSource = gpFrameBuffer;
pDest = gpFrameBuffer;
///zmiany ///zmiany
StripRegions[ 0 ].left = gsVIEWPORT_START_X ; StripRegions[ 0 ].left = gsVIEWPORT_START_X ;
StripRegions[ 0 ].right = gsVIEWPORT_END_X ; StripRegions[ 0 ].right = gsVIEWPORT_END_X ;
@@ -1060,6 +1107,11 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
Region.right = usWidth; Region.right = usWidth;
Region.bottom = gsVIEWPORT_WINDOW_START_Y + usHeight; Region.bottom = gsVIEWPORT_WINDOW_START_Y + usHeight;
if (Region.left >= Region.right)
{
break;
}
do do
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY); ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, 0, gsVIEWPORT_WINDOW_START_Y, pSource, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
@@ -1384,6 +1436,7 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
// Optimize Redundent tiles too! // Optimize Redundent tiles too!
//ExamineZBufferRect( (INT16)StripRegions[ cnt ].left, (INT16)StripRegions[ cnt ].top, (INT16)StripRegions[ cnt ].right, (INT16)StripRegions[ cnt ].bottom ); //ExamineZBufferRect( (INT16)StripRegions[ cnt ].left, (INT16)StripRegions[ cnt ].top, (INT16)StripRegions[ cnt ].right, (INT16)StripRegions[ cnt ].bottom );
#if 0
do do
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, StripRegions[ cnt ].left, StripRegions[ cnt ].top, gpFrameBuffer, (LPRECT)&( StripRegions[ cnt ] ), DDBLTFAST_NOCOLORKEY); ReturnCode = IDirectDrawSurface2_SGPBltFast(pDest, StripRegions[ cnt ].left, StripRegions[ cnt ].top, gpFrameBuffer, (LPRECT)&( StripRegions[ cnt ] ), DDBLTFAST_NOCOLORKEY);
@@ -1397,7 +1450,7 @@ void ScrollJA2Background(UINT32 uiDirection, INT16 sScrollXIncrement, INT16 sScr
break; break;
} }
} while (ReturnCode != DD_OK); } while (ReturnCode != DD_OK);
#endif
} }
sShiftX = 0; sShiftX = 0;
@@ -1515,6 +1568,7 @@ void RefreshScreen(void *DummyVariable)
static BOOLEAN fShowMouse; static BOOLEAN fShowMouse;
HRESULT ReturnCode; HRESULT ReturnCode;
static RECT Region; static RECT Region;
static INT16 sx, sy;
static POINT MousePos; static POINT MousePos;
static BOOLEAN fFirstTime = TRUE; static BOOLEAN fFirstTime = TRUE;
UINT32 uiTime; UINT32 uiTime;
@@ -1585,6 +1639,7 @@ void RefreshScreen(void *DummyVariable)
// //
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
// //
@@ -1653,6 +1708,13 @@ void RefreshScreen(void *DummyVariable)
// Either Method (1) or (2) // Either Method (1) or (2)
// //
{ {
if ( gfRenderScroll )
{
// ScrollJA2Background( guiScrollDirection, gsScrollXIncrement, gsScrollYIncrement, gpPrimarySurface, gpBackBuffer, TRUE, PREVIOUS_MOUSE_DATA );
ScrollJA2Background( guiScrollDirection, gsScrollXIncrement, gsScrollYIncrement, gpBackBuffer, gpBackBuffer, TRUE, PREVIOUS_MOUSE_DATA );
gfForceFullScreenRefresh = TRUE;
}
if (gfForceFullScreenRefresh == TRUE) if (gfForceFullScreenRefresh == TRUE)
{ {
// //
@@ -1678,7 +1740,6 @@ void RefreshScreen(void *DummyVariable)
} }
} while (ReturnCode != DD_OK); } while (ReturnCode != DD_OK);
} }
else else
{ {
@@ -1738,16 +1799,10 @@ void RefreshScreen(void *DummyVariable)
goto ENDOFLOOP; goto ENDOFLOOP;
} }
} while (ReturnCode != DD_OK); } while (ReturnCode != DD_OK);
} }
} }
} }
if ( gfRenderScroll )
{
ScrollJA2Background( guiScrollDirection, gsScrollXIncrement, gsScrollYIncrement, gpPrimarySurface, gpBackBuffer, TRUE, PREVIOUS_MOUSE_DATA );
}
gfIgnoreScrollDueToCenterAdjust = FALSE; gfIgnoreScrollDueToCenterAdjust = FALSE;
@@ -1826,7 +1881,7 @@ void RefreshScreen(void *DummyVariable)
do do
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(pTmpBuffer, 0, 0, gpPrimarySurface, &Region, DDBLTFAST_NOCOLORKEY); ReturnCode = IDirectDrawSurface2_SGPBltFast(pTmpBuffer, 0, 0, gpPrimarySurface, &rcWindow, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{ {
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
@@ -2003,7 +2058,7 @@ void RefreshScreen(void *DummyVariable)
Region.right = Region.left + gusMouseCursorWidth; Region.right = Region.left + gusMouseCursorWidth;
Region.bottom = Region.top + gusMouseCursorHeight; Region.bottom = Region.top + gusMouseCursorHeight;
if (Region.right > usScreenWidth) if (Region.right > usScreenWidth)
{ {
Region.right = usScreenWidth; Region.right = usScreenWidth;
} }
@@ -2015,17 +2070,17 @@ void RefreshScreen(void *DummyVariable)
if ((Region.right > Region.left)&&(Region.bottom > Region.top)) if ((Region.right > Region.left)&&(Region.bottom > Region.top))
{ {
// //
// Make sure the mouse background is marked for restore and coordinates are saved for the // Make sure the mouse background is marked for restore and coordinates are saved for the
// future restore // future restore
// //
gMouseCursorBackground[CURRENT_MOUSE_DATA].fRestore = TRUE; gMouseCursorBackground[CURRENT_MOUSE_DATA].fRestore = TRUE;
gMouseCursorBackground[CURRENT_MOUSE_DATA].usRight = (UINT16) Region.right - (UINT16) Region.left; gMouseCursorBackground[CURRENT_MOUSE_DATA].usRight = (INT16)Region.right - (INT16) Region.left;
gMouseCursorBackground[CURRENT_MOUSE_DATA].usBottom = (UINT16) Region.bottom - (UINT16) Region.top; gMouseCursorBackground[CURRENT_MOUSE_DATA].usBottom = (INT16)Region.bottom - (INT16) Region.top;
if (Region.left < 0) if (Region.left < 0)
{ {
gMouseCursorBackground[CURRENT_MOUSE_DATA].usLeft = (UINT16) (0 - Region.left); gMouseCursorBackground[CURRENT_MOUSE_DATA].usLeft = (INT16) (0 - Region.left);
gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseXPos = 0; gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseXPos = 0;
Region.left = 0; Region.left = 0;
} }
@@ -2149,10 +2204,14 @@ void RefreshScreen(void *DummyVariable)
// //
// Step (1) - Flip pages // Step (1) - Flip pages
// //
do Region.top = 0;
Region.left = 0;
Region.right = rcWindow.right - rcWindow.left;
Region.bottom = rcWindow.bottom - rcWindow.top;
if( 1==iScreenMode ) /* Windowed mode */
{ {
if( 1==iScreenMode ) /* Windowed mode */ do
{ {
ReturnCode = IDirectDrawSurface_Blt( ReturnCode = IDirectDrawSurface_Blt(
gpPrimarySurface, // dest surface gpPrimarySurface, // dest surface
&rcWindow, // dest rect &rcWindow, // dest rect
@@ -2160,32 +2219,48 @@ void RefreshScreen(void *DummyVariable)
NULL, // src rect (all of it) NULL, // src rect (all of it)
DDBLT_WAIT, DDBLT_WAIT,
NULL); NULL);
} if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
else
{ {
ReturnCode = IDirectDrawSurface_Flip( DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
{
goto ENDOFLOOP;
}
}
} while (ReturnCode != DD_OK);
gfRenderScroll = FALSE;
gfScrollStart = FALSE;
guiDirtyRegionCount = 0;
guiDirtyRegionExCount = 0;
gfForceFullScreenRefresh = FALSE;
}
else
{
do
{
ReturnCode = IDirectDrawSurface_Flip(
_gpPrimarySurface, _gpPrimarySurface,
NULL, NULL,
gGameExternalOptions.gfVSync ? DDFLIP_WAIT : 0x00000008l gGameExternalOptions.gfVSync ? DDFLIP_WAIT : 0x00000008l
); );
}
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
{ {
goto ENDOFLOOP; DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
}
}
} while (ReturnCode != DD_OK); if (ReturnCode == DDERR_SURFACELOST)
{
goto ENDOFLOOP;
}
}
} while (ReturnCode != DD_OK);
//
// Step (2) - Copy Primary Surface to the Back Buffer
//
//
// Step (2) - Copy Primary Surface to the Back Buffer
//
if ( gfRenderScroll ) if ( gfRenderScroll )
{ {
Region.left = 0; Region.left = 0;
@@ -2193,7 +2268,6 @@ void RefreshScreen(void *DummyVariable)
Region.right = gsVIEWPORT_END_X; //ods1 640; Region.right = gsVIEWPORT_END_X; //ods1 640;
Region.bottom = gsVIEWPORT_END_Y; Region.bottom = gsVIEWPORT_END_Y;
do do
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, 0, 0, gpPrimarySurface, &Region, DDBLTFAST_NOCOLORKEY); ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, 0, 0, gpPrimarySurface, &Region, DDBLTFAST_NOCOLORKEY);
@@ -2249,7 +2323,6 @@ void RefreshScreen(void *DummyVariable)
{ {
Region = gMouseCursorBackground[CURRENT_MOUSE_DATA].Region; Region = gMouseCursorBackground[CURRENT_MOUSE_DATA].Region;
do do
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseXPos, gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseYPos, gpPrimarySurface, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY); ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseXPos, gMouseCursorBackground[CURRENT_MOUSE_DATA].usMouseYPos, gpPrimarySurface, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
@@ -2265,94 +2338,93 @@ void RefreshScreen(void *DummyVariable)
} while (ReturnCode != DD_OK); } while (ReturnCode != DD_OK);
} }
if (gfForceFullScreenRefresh == TRUE ) if (gfForceFullScreenRefresh == TRUE)
{ {
// //
// Method (1) - We will be refreshing the entire screen // Method (1) - We will be refreshing the entire screen
// //
Region.left = 0; Region.left = 0;
Region.top = 0; Region.top = 0;
Region.right = SCREEN_WIDTH; Region.right = SCREEN_WIDTH;
Region.bottom = SCREEN_HEIGHT; Region.bottom = SCREEN_HEIGHT;
do
{
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, 0, 0, gpPrimarySurface, &Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
if (ReturnCode == DDERR_SURFACELOST)
{
goto ENDOFLOOP;
}
do }
{ } while (ReturnCode != DD_OK);
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, 0, 0, gpPrimarySurface, &Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) guiDirtyRegionCount = 0;
{ guiDirtyRegionExCount = 0;
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); gfForceFullScreenRefresh = FALSE;
if (ReturnCode == DDERR_SURFACELOST)
{
goto ENDOFLOOP;
}
}
} while (ReturnCode != DD_OK);
guiDirtyRegionCount = 0;
guiDirtyRegionExCount = 0;
gfForceFullScreenRefresh = FALSE;
} }
else else
{ {
for (uiIndex = 0; uiIndex < guiDirtyRegionCount; uiIndex++) for (uiIndex = 0; uiIndex < guiDirtyRegionCount; uiIndex++)
{
Region.left = gListOfDirtyRegions[uiIndex].iLeft;
Region.top = gListOfDirtyRegions[uiIndex].iTop;
Region.right = gListOfDirtyRegions[uiIndex].iRight;
Region.bottom = gListOfDirtyRegions[uiIndex].iBottom;
do
{ {
Region.left = gListOfDirtyRegions[uiIndex].iLeft; ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, gListOfDirtyRegions[uiIndex].iLeft, gListOfDirtyRegions[uiIndex].iTop, gpPrimarySurface, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
Region.top = gListOfDirtyRegions[uiIndex].iTop; if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
Region.right = gListOfDirtyRegions[uiIndex].iRight; {
Region.bottom = gListOfDirtyRegions[uiIndex].iBottom; DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
}
do if (ReturnCode == DDERR_SURFACELOST)
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, Region.left, Region.top, gpPrimarySurface, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY); goto ENDOFLOOP;
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) }
{ } while (ReturnCode != DD_OK);
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ ); }
}
if (ReturnCode == DDERR_SURFACELOST) guiDirtyRegionCount = 0;
{ gfForceFullScreenRefresh = FALSE;
goto ENDOFLOOP;
}
} while (ReturnCode != DD_OK);
}
guiDirtyRegionCount = 0;
gfForceFullScreenRefresh = FALSE;
} }
// Do extended dirty regions! // Do extended dirty regions!
for (uiIndex = 0; uiIndex < guiDirtyRegionExCount; uiIndex++) for (uiIndex = 0; uiIndex < guiDirtyRegionExCount; uiIndex++)
{ {
Region.left = gDirtyRegionsEx[uiIndex].iLeft; Region.left = gDirtyRegionsEx[uiIndex].iLeft;
Region.top = gDirtyRegionsEx[uiIndex].iTop; Region.top = gDirtyRegionsEx[uiIndex].iTop;
Region.right = gDirtyRegionsEx[uiIndex].iRight; Region.right = gDirtyRegionsEx[uiIndex].iRight;
Region.bottom = gDirtyRegionsEx[uiIndex].iBottom; Region.bottom = gDirtyRegionsEx[uiIndex].iBottom;
if ( ( Region.top < gsVIEWPORT_WINDOW_END_Y ) && gfRenderScroll ) if ( ( Region.top < gsVIEWPORT_WINDOW_END_Y ) && gfRenderScroll )
{
continue;
}
do
{
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, gDirtyRegionsEx[uiIndex].iLeft, gDirtyRegionsEx[uiIndex].iTop, gpPrimarySurface, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY);
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING))
{ {
continue; DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
} }
do if (ReturnCode == DDERR_SURFACELOST)
{ {
ReturnCode = IDirectDrawSurface2_SGPBltFast(gpBackBuffer, Region.left, Region.top, gpPrimarySurface, (LPRECT)&Region, DDBLTFAST_NOCOLORKEY); goto ENDOFLOOP;
if ((ReturnCode != DD_OK)&&(ReturnCode != DDERR_WASSTILLDRAWING)) }
{ } while (ReturnCode != DD_OK);
DirectXAttempt ( ReturnCode, __LINE__, __FILE__ );
}
if (ReturnCode == DDERR_SURFACELOST)
{
goto ENDOFLOOP;
}
} while (ReturnCode != DD_OK);
} }
}
guiDirtyRegionExCount = 0; guiDirtyRegionExCount = 0;
ENDOFLOOP: ENDOFLOOP:
@@ -2639,6 +2711,12 @@ HRESULT ReturnCode;
gusGreenMask = (UINT16) SurfaceDescription.ddpfPixelFormat.dwGBitMask; gusGreenMask = (UINT16) SurfaceDescription.ddpfPixelFormat.dwGBitMask;
gusBlueMask = (UINT16) SurfaceDescription.ddpfPixelFormat.dwBBitMask; gusBlueMask = (UINT16) SurfaceDescription.ddpfPixelFormat.dwBBitMask;
if (!gusRedMask)
{
MessageBox( NULL, "Jagged Alliance 2 windowed mode requires a color depth of 16bpp or less.", "Jagged Alliance 2", MB_ICONEXCLAMATION);
PostQuitMessage(1);
return FALSE;
}
// RGB 5,5,5 // RGB 5,5,5
if((gusRedMask==0x7c00) && (gusGreenMask==0x03e0) && (gusBlueMask==0x1f)) if((gusRedMask==0x7c00) && (gusGreenMask==0x03e0) && (gusBlueMask==0x1f))
+7 -1
View File
@@ -3170,7 +3170,13 @@ DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"Autoresolve3");
} }
break; break;
case '{': case '{':
if( CHEATER_CHEAT_LEVEL() ) if (_KeyDown( ALT) )
{
}
else if (_KeyDown( CTRL) )
{
}
else if( CHEATER_CHEAT_LEVEL() )
{ {
gpAR->ubMercs = 0; gpAR->ubMercs = 0;
fResetAutoResolve = TRUE; fResetAutoResolve = TRUE;
+2 -1
View File
@@ -1053,6 +1053,7 @@ void MapScreenMessageScrollBarCallBack( MOUSE_REGION *pRegion, INT32 iReason )
{ {
// where is the mouse? // where is the mouse?
GetCursorPos( &MousePos ); GetCursorPos( &MousePos );
ScreenToClient(ghWindow, &MousePos); // In window coords!
ubMouseYOffset = (UINT8) MousePos.y - MESSAGE_SCROLL_AREA_START_Y; ubMouseYOffset = (UINT8) MousePos.y - MESSAGE_SCROLL_AREA_START_Y;
@@ -1774,7 +1775,7 @@ void HandleExitsFromMapScreen( void )
break; break;
case MAP_EXIT_TO_TACTICAL: case MAP_EXIT_TO_TACTICAL:
SetCurrentWorldSector( sSelMapX, sSelMapY, ( UINT8 )iCurrentMapSectorZ ); SetCurrentWorldSector( sSelMapX, sSelMapY, ( INT8 )iCurrentMapSectorZ );
break; break;
case MAP_EXIT_TO_OPTIONS: case MAP_EXIT_TO_OPTIONS:
+1
View File
@@ -1269,6 +1269,7 @@ void GetUserInput()
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( DequeueEvent( &Event ) ) while( DequeueEvent( &Event ) )
{ {
+2 -2
View File
@@ -4558,9 +4558,9 @@ void InvestigateSector( UINT8 ubSectorID )
} }
else if( pSector->ubNumElites ) else if( pSector->ubNumElites )
{ {
pSector->ubNumTroops--; pSector->ubNumElites--;
ubNumToSend--; ubNumToSend--;
ubTroops[i]++; ubElites[i]++;
ubTotal++; ubTotal++;
} }
else else
+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+8 -1
View File
@@ -4674,6 +4674,7 @@ UINT32 HandleMapUI( )
sX = ( GetLastSectorIdInCharactersPath( &Menptr[gCharactersList[bSelectedDestChar].usSolID] ) % MAP_WORLD_X ); sX = ( GetLastSectorIdInCharactersPath( &Menptr[gCharactersList[bSelectedDestChar].usSolID] ) % MAP_WORLD_X );
sY = ( GetLastSectorIdInCharactersPath( &Menptr[gCharactersList[bSelectedDestChar].usSolID] ) / MAP_WORLD_X ); sY = ( GetLastSectorIdInCharactersPath( &Menptr[gCharactersList[bSelectedDestChar].usSolID] ) / MAP_WORLD_X );
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
RestoreBackgroundForMapGrid( sX, sY ); RestoreBackgroundForMapGrid( sX, sY );
// fMapPanelDirty = TRUE; // fMapPanelDirty = TRUE;
} }
@@ -4976,6 +4977,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
// while( DequeueSpecificEvent( &InputEvent, KEY_DOWN ) ) // doesn't work for some reason // while( DequeueSpecificEvent( &InputEvent, KEY_DOWN ) ) // doesn't work for some reason
{ {
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
// HOOK INTO MOUSE HOOKS // HOOK INTO MOUSE HOOKS
switch(InputEvent.usEvent) switch(InputEvent.usEvent)
@@ -5354,7 +5356,10 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
case '\\': case '\\':
#ifdef JA2TESTVERSION #ifdef JA2TESTVERSION
if( fCtrl ) if (fAlt)
{
}
else if( fCtrl )
{ {
DumpItemsList(); DumpItemsList();
} }
@@ -6261,6 +6266,7 @@ BOOLEAN GetMouseMapXY( INT16 *psMapWorldX, INT16 *psMapWorldY )
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
if(fZoomFlag) if(fZoomFlag)
{ {
@@ -8504,6 +8510,7 @@ BOOLEAN IsCursorWithInRegion(INT16 sLeft, INT16 sRight, INT16 sTop, INT16 sBotto
// get cursor position // get cursor position
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
// is it within region? // is it within region?
+2 -1
View File
@@ -125,7 +125,8 @@ void ResetMilitia()
if ( gWorldSectorX !=0 && gWorldSectorY != 0 && NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) ) if ( gWorldSectorX !=0 && gWorldSectorY != 0 && NumEnemiesInSector( gWorldSectorX, gWorldSectorY ) )
fBattleInProgress = TRUE; fBattleInProgress = TRUE;
if( ( gfStrategicMilitiaChangesMade && !fBattleInProgress ) || gTacticalStatus.uiFlags & LOADING_SAVED_GAME || gfMSResetMilitia ) // if( ( gfStrategicMilitiaChangesMade && !fBattleInProgress ) || gTacticalStatus.uiFlags & LOADING_SAVED_GAME || gfMSResetMilitia )
if( gfStrategicMilitiaChangesMade || gTacticalStatus.uiFlags & LOADING_SAVED_GAME || gfMSResetMilitia )
{ {
gfStrategicMilitiaChangesMade = FALSE; gfStrategicMilitiaChangesMade = FALSE;
+1
View File
@@ -1520,6 +1520,7 @@ void GetShopKeeperInterfaceUserInput()
POINT MousePos; POINT MousePos;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
while( DequeueEvent( &Event ) ) while( DequeueEvent( &Event ) )
{ {
+9 -1
View File
@@ -1163,7 +1163,15 @@ BOOLEAN InternalAddSoldierToSector( UINT8 ubID, BOOLEAN fCalculateDirection, BOO
{ {
sGridNo = FindGridNoFromSweetSpotWithStructDataUsingGivenDirectionFirst( pSoldier, STANDING, pSoldier->sInsertionGridNo, 12, &ubCalculatedDirection, FALSE, pSoldier->ubInsertionDirection ); sGridNo = FindGridNoFromSweetSpotWithStructDataUsingGivenDirectionFirst( pSoldier, STANDING, pSoldier->sInsertionGridNo, 12, &ubCalculatedDirection, FALSE, pSoldier->ubInsertionDirection );
// ATE: Override insertion direction // ATE: Override insertion direction
pSoldier->ubInsertionDirection = ubCalculatedDirection; if (sGridNo == NOWHERE)
{
// Well, we gotta place this soldier/vehicle somewhere. Just use the first position for now
sGridNo = pSoldier->sGridNo = pSoldier->sInsertionGridNo;
}
else
{
pSoldier->ubInsertionDirection = ubCalculatedDirection;
}
} }
else else
{ {
+1
View File
@@ -2106,6 +2106,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier )
if ( pSoldier->usPathIndex == pSoldier->usPathDataSize ) if ( pSoldier->usPathIndex == pSoldier->usPathDataSize )
{ {
pSoldier->usPathIndex = pSoldier->usPathDataSize;
// Stop, don't do anything..... // Stop, don't do anything.....
} }
else else
+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+15
View File
@@ -1419,6 +1419,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
BOOLEAN fGoodCheatLevelKey = FALSE; BOOLEAN fGoodCheatLevelKey = FALSE;
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
GetMouseMapPos( &usMapPos ); GetMouseMapPos( &usMapPos );
@@ -1578,6 +1579,9 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
// Decrease global busy counter... // Decrease global busy counter...
gTacticalStatus.ubAttackBusyCount = 0; gTacticalStatus.ubAttackBusyCount = 0;
#ifdef DEBUG_ATTACKBUSY
OutputDebugString( "Resetting attack busy due to keyboard interrupt.\n");
#endif
guiPendingOverrideEvent = LU_ENDUILOCK; guiPendingOverrideEvent = LU_ENDUILOCK;
UIHandleLUIEndLock( NULL ); UIHandleLUIEndLock( NULL );
@@ -2875,6 +2879,14 @@ void GetKeyboardInput( UINT32 *puiNewEvent )
#endif #endif
case 'l': case 'l':
if (fAlt )
{
}
else if (fCtrl)
{
}
else
/* /*
if( fAlt ) if( fAlt )
{ {
@@ -5207,6 +5219,9 @@ void EscapeUILock( )
// Decrease global busy counter... // Decrease global busy counter...
gTacticalStatus.ubAttackBusyCount = 0; gTacticalStatus.ubAttackBusyCount = 0;
#ifdef DEBUG_ATTACKBUSY
OutputDebugString( "Resetting attack busy due to escape of UI lock.\n");
#endif
guiPendingOverrideEvent = LU_ENDUILOCK; guiPendingOverrideEvent = LU_ENDUILOCK;
UIHandleLUIEndLock( NULL ); UIHandleLUIEndLock( NULL );
+19 -15
View File
@@ -2152,7 +2152,23 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
// Get new gridno! // Get new gridno!
sCheckGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( ubOpponentDir ) ); sCheckGridNo = NewGridNo( (UINT16)pSoldier->sGridNo, (UINT16)DirectionInc( ubOpponentDir ) );
if ( !OKFallDirection( pSoldier, sCheckGridNo, pSoldier->bLevel, ubOpponentDir, pSoldier->usAnimState ) ) if ( OKFallDirection( pSoldier, sCheckGridNo, pSoldier->bLevel, ubOpponentDir, pSoldier->usAnimState ) )
{
// then do it! The functions have already made sure that we have a
// pair of worthy opponents, etc., so we're not just wasting our time
// if necessary, swap the usItem from holster into the hand position
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"decideactionred: if necessary, swap the usItem from holster into the hand position");
if (BestThrow.bWeaponIn != HANDPOS)
RearrangePocket(pSoldier,HANDPOS,BestThrow.bWeaponIn,FOREVER);
pSoldier->usActionData = BestThrow.sTarget;
pSoldier->bAimTime = BestThrow.ubAimTime;
return(AI_ACTION_TOSS_PROJECTILE);
}
else
{ {
// can't fire! // can't fire!
BestThrow.ubPossible = FALSE; BestThrow.ubPossible = FALSE;
@@ -2167,19 +2183,6 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK)
} }
} }
} }
// then do it! The functions have already made sure that we have a
// pair of worthy opponents, etc., so we're not just wasting our time
// if necessary, swap the usItem from holster into the hand position
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"decideactionred: if necessary, swap the usItem from holster into the hand position");
if (BestThrow.bWeaponIn != HANDPOS)
RearrangePocket(pSoldier,HANDPOS,BestThrow.bWeaponIn,FOREVER);
pSoldier->usActionData = BestThrow.sTarget;
pSoldier->bAimTime = BestThrow.ubAimTime;
return(AI_ACTION_TOSS_PROJECTILE);
} }
else // toss/throw/launch not possible else // toss/throw/launch not possible
{ {
@@ -3918,7 +3921,8 @@ INT8 DecideActionBlack(SOLDIERTYPE *pSoldier)
bWeaponIn = FindAIUsableObjClass( pSoldier, (IC_BLADE | IC_THROWING_KNIFE) ); bWeaponIn = FindAIUsableObjClass( pSoldier, (IC_BLADE | IC_THROWING_KNIFE) );
// if the soldier does have a usable knife somewhere // if the soldier does have a usable knife somewhere
if (bWeaponIn != NO_SLOT) // 0verhaul: And is not a tank!
if (bWeaponIn != NO_SLOT && !TANK( pSoldier))
{ {
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"try to stab"); DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"try to stab");
BestStab.bWeaponIn = bWeaponIn; BestStab.bWeaponIn = bWeaponIn;
+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+1 -1
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
+5 -2
View File
@@ -31,7 +31,7 @@
#include "PreBattle Interface.h" #include "PreBattle Interface.h"
#endif #endif
#include "Console.h" //#include "Console.h"
#include "Lua Interpreter.h" #include "Lua Interpreter.h"
// rain // rain
@@ -190,7 +190,8 @@ void GameLoop(void)
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop: get mouse position"); //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop: get mouse position");
GetCursorPos(&MousePos); GetCursorPos(&MousePos);
ScreenToClient(ghWindow, &MousePos); // In window coords!
// Hook into mouse stuff for MOVEMENT MESSAGES // Hook into mouse stuff for MOVEMENT MESSAGES
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop: get mouse hook"); //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop: get mouse hook");
MouseSystemHook(MOUSE_POS, (UINT16)MousePos.x ,(UINT16)MousePos.y ,_LeftButtonDown, _RightButtonDown); MouseSystemHook(MOUSE_POS, (UINT16)MousePos.x ,(UINT16)MousePos.y ,_LeftButtonDown, _RightButtonDown);
@@ -352,6 +353,7 @@ void GameLoop(void)
} }
#endif #endif
#if 0
if( gGameSettings.fOptions[ TOPTION_LOW_CPU_USAGE ] == TRUE ) if( gGameSettings.fOptions[ TOPTION_LOW_CPU_USAGE ] == TRUE )
{ {
// decrease CPU load patch from MTX (http://www.ja-galaxy-forum.com/board/ubbthreads.php/ubb/showflat/Number/102405/page/1#Post102405) // decrease CPU load patch from MTX (http://www.ja-galaxy-forum.com/board/ubbthreads.php/ubb/showflat/Number/102405/page/1#Post102405)
@@ -367,6 +369,7 @@ void GameLoop(void)
if( sleeptime > 0 ) if( sleeptime > 0 )
Sleep(sleeptime); Sleep(sleeptime);
} }
#endif
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop done"); //DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"GameLoop done");
} }
+14 -7
View File
@@ -4,14 +4,15 @@ Microsoft Visual Studio Solution File, Format Version 9.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ja2_2005Express", "ja2_2005Express.vcproj", "{F44669E7-74AC-444B-B75F-F16F4B9F0265}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ja2_2005Express", "ja2_2005Express.vcproj", "{F44669E7-74AC-444B-B75F-F16F4B9F0265}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{5234CD2E-97F1-42FF-828D-CE0A1B46805E} = {5234CD2E-97F1-42FF-828D-CE0A1B46805E} {5234CD2E-97F1-42FF-828D-CE0A1B46805E} = {5234CD2E-97F1-42FF-828D-CE0A1B46805E}
{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C} = {262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C} {F962CFA1-2215-4124-938F-253973A27591} = {F962CFA1-2215-4124-938F-253973A27591}
{6283CE93-2960-4596-8E74-7A6FBA8716FF} = {6283CE93-2960-4596-8E74-7A6FBA8716FF}
{D4BDA6AD-9B61-4953-892D-DA3F8CC7E096} = {D4BDA6AD-9B61-4953-892D-DA3F8CC7E096}
{27A49DAF-3F5A-4FF2-B943-9559F0B63032} = {27A49DAF-3F5A-4FF2-B943-9559F0B63032}
{A83DA7DA-2C31-45D8-9A69-B4993A885E76} = {A83DA7DA-2C31-45D8-9A69-B4993A885E76}
{AB8837DB-0435-40C7-916A-0AACF5CFF1C4} = {AB8837DB-0435-40C7-916A-0AACF5CFF1C4}
{FC1938E8-9253-49A8-AA99-4639BBB46C1B} = {FC1938E8-9253-49A8-AA99-4639BBB46C1B}
{60D793F2-90B4-43C9-83B5-221EE11B37E6} = {60D793F2-90B4-43C9-83B5-221EE11B37E6} {60D793F2-90B4-43C9-83B5-221EE11B37E6} = {60D793F2-90B4-43C9-83B5-221EE11B37E6}
{FC1938E8-9253-49A8-AA99-4639BBB46C1B} = {FC1938E8-9253-49A8-AA99-4639BBB46C1B}
{AB8837DB-0435-40C7-916A-0AACF5CFF1C4} = {AB8837DB-0435-40C7-916A-0AACF5CFF1C4}
{A83DA7DA-2C31-45D8-9A69-B4993A885E76} = {A83DA7DA-2C31-45D8-9A69-B4993A885E76}
{27A49DAF-3F5A-4FF2-B943-9559F0B63032} = {27A49DAF-3F5A-4FF2-B943-9559F0B63032}
{D4BDA6AD-9B61-4953-892D-DA3F8CC7E096} = {D4BDA6AD-9B61-4953-892D-DA3F8CC7E096}
{6283CE93-2960-4596-8E74-7A6FBA8716FF} = {6283CE93-2960-4596-8E74-7A6FBA8716FF}
{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C} = {262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Editor_2005Express", "Editor\Editor_2005Express.vcproj", "{60D793F2-90B4-43C9-83B5-221EE11B37E6}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Editor_2005Express", "Editor\Editor_2005Express.vcproj", "{60D793F2-90B4-43C9-83B5-221EE11B37E6}"
@@ -32,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TileEngine_2005Express", "T
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utils_2005Express", "Utils\Utils_2005Express.vcproj", "{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utils_2005Express", "Utils\Utils_2005Express.vcproj", "{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Console_2005Express", "Console\Console_2005Express.vcproj", "{F962CFA1-2215-4124-938F-253973A27591}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
@@ -78,6 +81,10 @@ Global
{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}.Debug|Win32.Build.0 = Debug|Win32 {262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}.Debug|Win32.Build.0 = Debug|Win32
{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}.Release|Win32.ActiveCfg = Release|Win32 {262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}.Release|Win32.ActiveCfg = Release|Win32
{262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}.Release|Win32.Build.0 = Release|Win32 {262A5F80-0B99-4E8E-A6C7-74CB1FD0A67C}.Release|Win32.Build.0 = Release|Win32
{F962CFA1-2215-4124-938F-253973A27591}.Debug|Win32.ActiveCfg = Debug|Win32
{F962CFA1-2215-4124-938F-253973A27591}.Debug|Win32.Build.0 = Debug|Win32
{F962CFA1-2215-4124-938F-253973A27591}.Release|Win32.ActiveCfg = Release|Win32
{F962CFA1-2215-4124-938F-253973A27591}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
+25 -5
View File
@@ -20,7 +20,7 @@
OutputDirectory="C:\Program Files\Jagged Alliance 2 1.13" OutputDirectory="C:\Program Files\Jagged Alliance 2 1.13"
IntermediateDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets=".\ja2_2005Express.vsprops" InheritedPropertySheets=".\ja2_2005Express.vsprops;.\ja2_2005ExpressDebug.vsprops"
UseOfMFC="0" UseOfMFC="0"
CharacterSet="0" CharacterSet="0"
> >
@@ -370,10 +370,6 @@
RelativePath=".\Options Screen.h" RelativePath=".\Options Screen.h"
> >
</File> </File>
<File
RelativePath=".\Res\resource.h"
>
</File>
<File <File
RelativePath=".\SaveLoadGame.h" RelativePath=".\SaveLoadGame.h"
> >
@@ -404,6 +400,26 @@
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
> >
<File
RelativePath=".\Console\Console.rc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCResourceCompilerTool"
AdditionalIncludeDirectories=".\Res"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCResourceCompilerTool"
AdditionalIncludeDirectories=".\Res"
/>
</FileConfiguration>
</File>
<File <File
RelativePath=".\Res\ja2.rc" RelativePath=".\Res\ja2.rc"
> >
@@ -412,6 +428,10 @@
RelativePath=".\Res\jagged3.ico" RelativePath=".\Res\jagged3.ico"
> >
</File> </File>
<File
RelativePath=".\Res\resource.h"
>
</File>
</Filter> </Filter>
<File <File
RelativePath=".\fmodvc.lib" RelativePath=".\fmodvc.lib"
+1 -1
View File
@@ -6,7 +6,7 @@
> >
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\Utils;..\TileEngine;..\TacticalAI;..\Tactical;..\Strategic;&quot;..\Standard Gaming Platform&quot;;..\Res;..\lua;..\Laptop;..\Editor;..\;$(NOINHERIT)" AdditionalIncludeDirectories="..\Utils;..\TileEngine;..\TacticalAI;..\Tactical;..\Strategic;&quot;..\Standard Gaming Platform&quot;;..\Res;..\lua;..\Laptop;..\Editor;..\;..\Console;$(NOINHERIT)"
PreprocessorDefinitions="JA2;CINTERFACE;XML_STATIC" PreprocessorDefinitions="JA2;CINTERFACE;XML_STATIC"
Detect64BitPortabilityProblems="false" Detect64BitPortabilityProblems="false"
/> />
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="ja2_2005ExpressDebug"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="JA2BETAVERSION;JA2TESTVERSION;DEBUG_ATTACKBUSY"
/>
</VisualStudioPropertySheet>
-126
View File
@@ -1,126 +0,0 @@
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>
#include <conio.h>
#include "Console.h"
#include "Lua Interpreter.h"
#ifndef _USE_OLD_IOSTREAMS
using namespace std;
#endif
extern HWND ghWindow;
// maximum mumber of lines the output console should have
static const WORD MAX_CONSOLE_LINES = 500;
BOOL WINAPI ControlHandlerRoutine(
DWORD dwCtrlType
)
{
switch (dwCtrlType)
{
case CTRL_CLOSE_EVENT:
// Tell the main window that the console wants out
PostMessage( ghWindow, WM_USER, 0, 0 );
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
// Ignore all of these signals. The game itself will handle the important stuff anyway.
return TRUE;
}
return FALSE;
}
void CreateConsole()
{
int hConHandle;
long lStdHandle;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
FILE *fp;
// HWND hConWindow;
// allocate a console for this app
AllocConsole();
// Eliminate the game-killing control signals
SetConsoleCtrlHandler( ControlHandlerRoutine, TRUE );
// set the screen buffer to be big enough to let us scroll text
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&coninfo);
coninfo.dwSize.Y = MAX_CONSOLE_LINES;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
coninfo.dwSize);
// redirect unbuffered STDOUT to the console
lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
// redirect unbuffered STDIN to the console
lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "r" );
*stdin = *fp;
setvbuf( stdin, NULL, _IONBF, 0 );
// redirect unbuffered STDERR to the console
lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
fp = _fdopen( hConHandle, "w" );
*stderr = *fp;
setvbuf( stderr, NULL, _IONBF, 0 );
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
// point to console as well
ios::sync_with_stdio();
// Print the warning message
printf( "Do not close this window!\n");
printf( "> " );
}
void PollConsole ()
{
static int buf_idx = 0;
static char buf[16384];
if (_kbhit() )
{
buf[ buf_idx++ ] = _getche();
if (buf[ buf_idx-1] == 8) {
_putch( ' ');
buf_idx--;
if (buf_idx > 0)
{
_putch( 8 );
buf_idx--;
}
}
}
if (buf[ buf_idx-1] == '\r')
{
buf[ buf_idx-1] = 0;
printf( "\n");
EvalLua( buf);
printf( "\n> ");
buf_idx = 0;
}
}
//End of File
-9
View File
@@ -1,9 +0,0 @@
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
void CreateConsole();
void PollConsole();
#endif
/* End of File */
+1 -9
View File
@@ -20,7 +20,7 @@
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="4" ConfigurationType="4"
InheritedPropertySheets="..\ja2_2005Express.vsprops" InheritedPropertySheets="..\ja2_2005Express.vsprops;..\ja2_2005ExpressDebug.vsprops"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
@@ -145,10 +145,6 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd" Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
> >
<File
RelativePath=".\Console.h"
>
</File>
<File <File
RelativePath=".\lauxlib.h" RelativePath=".\lauxlib.h"
> >
@@ -183,10 +179,6 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File
RelativePath=".\Console.cpp"
>
</File>
<File <File
RelativePath=".\lua.cpp" RelativePath=".\lua.cpp"
> >
-16
View File
@@ -1,16 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ja2.rc
//
#define IDI_ICON1 113
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif