Combine Event.h/Events.h

This commit is contained in:
UnknownShadow200 2017-11-19 04:12:59 +11:00
parent c5c2e51b6f
commit 7dccf90f18
31 changed files with 133 additions and 256 deletions

View File

@ -36,7 +36,7 @@ namespace ClassicalSharp.Textures {
string line;
while ((line = reader.ReadLine()) != null) {
line = line.Trim();
if (line.Length == 0 || line[0] == '#') continue;
if (line.Length == 0) continue;
Entries.Add(line);
}
}

View File

@ -7,7 +7,7 @@
#include "PackedCol.h"
#include "Camera.h"
#include "Player.h"
#include "Events.h"
#include "Event.h"
GfxResourceID axisLines_vb;
#define axisLines_numVertices 12

View File

@ -6,7 +6,7 @@
#include "GraphicsAPI.h"
#include "GraphicsCommon.h"
#include "GraphicsEnums.h"
#include "Events.h"
#include "Event.h"
#include "TerrainAtlas.h"
#include "ExtMath.h"
#include "Platform.h"

View File

@ -3,7 +3,7 @@
#include "Typedefs.h"
#include "GameStructs.h"
#include "VertexStructs.h"
#include "Events.h"
#include "Event.h"
#include "GraphicsEnums.h"
/* Renders map sides and map edges (horizon) as large quads.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,7 +1,7 @@
#include "Chat.h"
#include "Stream.h"
#include "Platform.h"
#include "Events.h"
#include "Event.h"
#include "Game.h"
#include "ErrorHandler.h"
#include "ServerConnection.h"

View File

@ -1,6 +1,6 @@
#include "ChunkUpdater.h"
#include "Constants.h"
#include "Events.h"
#include "Event.h"
#include "ExtMath.h"
#include "FrustumCulling.h"
#include "Funcs.h"

View File

@ -2,7 +2,7 @@
#define CC_CHUNKUPDATER_H
#include "Typedefs.h"
#include "Vectors.h"
#include "Events.h"
#include "Event.h"
/* Manages the process of building/deleting chunk meshes.
Also sorts chunks so nearest chunks are ordered first, and calculates chunk visibility.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -198,7 +198,6 @@
<ClInclude Include="EnvRenderer.h" />
<ClInclude Include="ErrorHandler.h" />
<ClInclude Include="Event.h" />
<ClInclude Include="Events.h" />
<ClInclude Include="Formats.h" />
<ClInclude Include="FrustumCulling.h" />
<ClInclude Include="Deflate.h" />

View File

@ -61,12 +61,6 @@
<Filter Include="Source Files\Map">
<UniqueIdentifier>{cb26e83f-9153-4964-9dc2-13502fbb1d1b}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Events">
<UniqueIdentifier>{a912f0d5-3ceb-4e7e-ba4e-28170c634047}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Events">
<UniqueIdentifier>{03efa5de-9e49-4185-bb40-fa5e5a2846e6}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\TexturePack">
<UniqueIdentifier>{b5bd9aed-4b11-4f9f-86da-3187d3f4f260}</UniqueIdentifier>
</Filter>
@ -318,12 +312,6 @@
<ClInclude Include="DisplayDevice.h">
<Filter>Header Files\Platform\Window</Filter>
</ClInclude>
<ClInclude Include="Event.h">
<Filter>Header Files\Events</Filter>
</ClInclude>
<ClInclude Include="Events.h">
<Filter>Header Files\Events</Filter>
</ClInclude>
<ClInclude Include="Window.h">
<Filter>Header Files\Platform\Window</Filter>
</ClInclude>
@ -384,6 +372,9 @@
<ClInclude Include="AsyncDownloader.h">
<Filter>Header Files\Network</Filter>
</ClInclude>
<ClInclude Include="Event.h">
<Filter>Header Files\Game</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Noise.c">
@ -512,9 +503,6 @@
<ClCompile Include="DisplayDevice.c">
<Filter>Source Files\Platform\Window</Filter>
</ClCompile>
<ClCompile Include="Event.c">
<Filter>Source Files\Events</Filter>
</ClCompile>
<ClCompile Include="WinWindow.c">
<Filter>Source Files\Platform</Filter>
</ClCompile>
@ -593,5 +581,8 @@
<ClCompile Include="ServerConnection.c">
<Filter>Source Files\Network</Filter>
</ClCompile>
<ClCompile Include="Event.c">
<Filter>Source Files\Game</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -2,7 +2,7 @@
#include "ExtMath.h"
#include "World.h"
#include "Block.h"
#include "Events.h"
#include "Event.h"
#include "Game.h"
#include "Player.h"
#include "Camera.h"

View File

@ -9,7 +9,7 @@
#include "Block.h"
#include "Platform.h"
#include "SkyboxRenderer.h"
#include "Events.h"
#include "Event.h"
#include "Utils.h"
GfxResourceID env_cloudsVb, env_skyVb, env_cloudsTex;

View File

@ -4,8 +4,8 @@
#include "String.h"
#include "Stream.h"
#include "Vectors.h"
/* Helper method for managing events.
Copyright 2017 ClassicalSharp | Licensed under BSD-3
/* Helper method for managing events, and contains all events.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Maximum number of event handlers that can be registered. */
@ -74,4 +74,72 @@ void Event_UnregisterBlock(Event_Block* handlers, Event_Block_Callback handler);
void Event_RaiseMouseMove(Event_MouseMove* handlers, Int32 xDelta, Int32 yDelta);
void Event_RegisterMouseMove(Event_MouseMove* handlers, Event_MouseMove_Callback handler);
void Event_UnregisterMouseMove(Event_MouseMove* handlers, Event_MouseMove_Callback handler);
Event_EntityID EntityEvents_Added; /* Entity is spawned in the current world. */
Event_EntityID EntityEvents_Removed; /* Entity is despawned from the current world. */
Event_EntityID TabListEvents_Added; /* Tab list entry is created. */
Event_EntityID TabListEvents_Changed; /* Tab list entry is modified. */
Event_EntityID TabListEvents_Removed; /* Tab list entry is removed. */
Event_Void TextureEvents_AtlasChanged; /* Terrain atlas (terrain.png) is changed. */
Event_Void TextureEvents_PackChanged; /* Texture pack is changed. */
Event_Stream TextureEvents_FileChanged; /* File in a texture pack is changed. (terrain.png, rain.png) */
Event_Void GfxEvents_ViewDistanceChanged; /* View/fog distance is changed. */
Event_Void GfxEvents_ProjectionChanged; /* Projection matrix has changed. */
Event_Void GfxEvents_ContextLost; /* Context is destroyed after having been previously created. */
Event_Void GfxEvents_ContextRecreated; /* context is recreated after having been previously lost. */
Event_Block UserEvents_BlockChanged; /* User changes a block. */
Event_Void UserEvents_HackPermissionsChanged; /* Hack permissions of the player changes. */
Event_Void UserEvents_HeldBlockChanged; /* Held block in hotbar changes. */
Event_Void BlockEvents_PermissionsChanged; /* Block permissions (can place/delete) for a block changes. */
Event_Void BlockEvents_BlockDefChanged; /* Block definition is changed or removed. */
Event_Void WorldEvents_NewMap; /* Player begins loading a new world. */
Event_Real32 WorldEvents_MapLoading; /* Portion of world is decompressed/generated. (Arg is progress from 0-1) */
Event_Void WorldEvents_MapLoaded; /* New world has finished loading, player can now interact with it. */
Event_Int32 WorldEvents_EnvVarChanged; /* World environment variable changed by player/CPE/WoM config. */
/* Environment variable identifiers*/
typedef Int32 EnvVar;
#define EnvVar_EdgeBlock 0
#define EnvVar_SidesBlock 1
#define EnvVar_EdgeHeight 2
#define EnvVar_SidesOffset 3
#define EnvVar_CloudsHeight 4
#define EnvVar_CloudsSpeed 5
#define EnvVar_WeatherSpeed 6
#define EnvVar_WeatherFade 7
#define EnvVar_Weather 8
#define EnvVar_ExpFog 9
#define EnvVar_SkyboxHorSpeed 10
#define EnvVar_SkyboxVerSpeed 11
#define EnvVar_SkyCol 12
#define EnvVar_CloudsCol 13
#define EnvVar_FogCol 14
#define EnvVar_SunCol 15
#define EnvVar_ShadowCol 16
Event_Void WindowEvents_Moved; /* Window is moved. */
Event_Void WindowEvents_Resized; /* Window is resized. */
Event_Void WindowEvents_Closing; /* Window is about to close. */
Event_Void WindowEvents_Closed; /* Window has closed. */
Event_Void WindowEvents_VisibilityChanged; /* Visibility of the window changes. */
Event_Void WindowEvents_FocusChanged; /* Focus of the window changes. */
Event_Void WindowEvents_WindowStateChanged; /* WindowState of the window changes. */
Event_Void WindowEvents_MouseLeave; /* Mouse cursor leaves window bounds. */
Event_Void WindowEvents_MouseEnter; /* Mouse cursor re-enters window bounds. */
Event_Int32 KeyEvents_Press; /* Raised when a character is typed. Arg is a character. */
Event_Int32 KeyEvents_Down; /* Raised when a key is pressed. Arg is a member of Key enumeration. */
Event_Int32 KeyEvents_Up; /* Raised when a key is released. Arg is a member of Key enumeration. */
Event_MouseMove MouseEvents_Moved; /* Mouse position is changed. (Arg is delta from last position) */
Event_Int32 MouseEvents_Down; /* Mouse button is pressed. (Arg is MouseButton member) */
Event_Int32 MouseEvents_Up; /* Mouse button is released. (Arg is MouseButton member) */
Event_Real32 MouseEvents_Wheel; /* Mouse wheel is moved/scrolled. (Arg is wheel delta) */
#endif

View File

@ -1,143 +0,0 @@
#ifndef CC_EVENTS_H
#define CC_EVENTS_H
#include "Event.h"
#include "Typedefs.h"
/* Contains the various events that are raised by the client.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
/* Raised when an entity is spawned in the current world. */
Event_EntityID EntityEvents_Added;
/* Raised when an entity is despawned from the current world. */
Event_EntityID EntityEvents_Removed;
/* Raised when a tab list entry is created. */
Event_EntityID TabListEvents_Added;
/* Raised when a tab list entry is modified. */
Event_EntityID TabListEvents_Changed;
/* Raised when a tab list entry is removed. */
Event_EntityID TabListEvents_Removed;
/* Raised when the terrain atlas ("terrain.png") is changed. */
Event_Void TextureEvents_AtlasChanged;
/* Raised when the texture pack is changed. */
Event_Void TextureEvents_PackChanged;
/* Raised when a file in a texture pack is changed. (such as "terrain.png", "rain.png") */
Event_Stream TextureEvents_FileChanged;
/* Raised when the user changed their view/fog distance. */
Event_Void GfxEvents_ViewDistanceChanged;
/* Raised when the projection matrix changes. */
Event_Void GfxEvents_ProjectionChanged;
/* Event raised when a context is destroyed after having been previously lost. */
Event_Void GfxEvents_ContextLost;
/* Event raised when a context is recreated after having been previously lost. */
Event_Void GfxEvents_ContextRecreated;
/* Raised when the user changes a block. */
Event_Block UserEvents_BlockChanged;
/* Raised when when the hack permissions of the player changes. */
Event_Void UserEvents_HackPermissionsChanged;
/* Raised when when the held block in hotbar changes. */
Event_Void UserEvents_HeldBlockChanged;
/* Raised when the block permissions(can place or delete a block) for the player changes. */
Event_Void BlockEvents_PermissionsChanged;
/* Raised when a block definition is changed. */
Event_Void BlockEvents_BlockDefChanged;
/* Raised when the player joins and begins loading a new world. */
Event_Void WorldEvents_NewMap;
/* Raised when a portion of the world is read and decompressed, or generated.
The floating point argument is progress (from 0 to 1). */
Event_Real32 WorldEvents_MapLoading;
/* Raised when new world has finished loading and the player can now interact with it. */
Event_Void WorldEvents_MapLoaded;
/* Raised when an environment variable of the world is changed by the user, CPE, or WoM config. */
Event_Int32 WorldEvents_EnvVarChanged;
/* Environment variable identifiers*/
typedef Int32 EnvVar;
#define EnvVar_EdgeBlock 0
#define EnvVar_SidesBlock 1
#define EnvVar_EdgeHeight 2
#define EnvVar_SidesOffset 3
#define EnvVar_CloudsHeight 4
#define EnvVar_CloudsSpeed 5
#define EnvVar_WeatherSpeed 6
#define EnvVar_WeatherFade 7
#define EnvVar_Weather 8
#define EnvVar_ExpFog 9
#define EnvVar_SkyboxHorSpeed 10
#define EnvVar_SkyboxVerSpeed 11
#define EnvVar_SkyCol 12
#define EnvVar_CloudsCol 13
#define EnvVar_FogCol 14
#define EnvVar_SunCol 15
#define EnvVar_ShadowCol 16
/*
The Open Toolkit Library License
Copyright (c) 2006 - 2009 the Open Toolkit library.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
/* Raised when the window is moved. */
Event_Void WindowEvents_OnMove;
/* Raised whene the window is resized. */
Event_Void WindowEvents_OnResize;
/* Raised when the window is about to close. */
Event_Void WindowEvents_OnClosing;
/* Raised after the window has closed. */
Event_Void WindowEvents_OnClosed;
/* Raised the visibility of the window changes. */
Event_Void WindowEvents_OnVisibleChanged;
/* Raised when the focus of the window changes. */
Event_Void WindowEvents_OnFocusedChanged;
/* Raised when the WindowState of the window changes. */
Event_Void WindowEvents_OnWindowStateChanged;
/* Raised whenever the mouse cursor leaves the bounds of the window. */
Event_Void WindowEvents_OnMouseLeave;
/* Raised whenever the mouse cursor enters the bounds of the window. */
Event_Void WindowEvents_OnMouseEnter;
/* Raised when a character is typed. Arg is a character. */
Event_Int32 KeyEvents_KeyPress;
/* Raised when a key is pressed. Arg is a member of Key enumeration. */
Event_Int32 KeyEvents_KeyDown;
/* Raised when a key is released. Arg is a member of Key enumeration. */
Event_Int32 KeyEvents_KeyUp;
/*Raised when mouse position is changed. Arg is delta from last position. */
Event_MouseMove MouseEvents_Move;
/* Raised when a button is pressed. Arg is a member of MouseButton enum. */
Event_Int32 MouseEvents_ButtonDown;
/* Raised when a button is released. Arg is a member of MouseButton enum. */
Event_Int32 MouseEvents_ButtonUp;
/* Raised when mouse wheel is moved / scrolled. Arg is wheel delta. */
Event_Real32 MouseEvents_WheelChanged;
#endif

View File

@ -4,7 +4,7 @@
#include "Game.h"
#include "Screens.h"
#include "Block.h"
#include "Events.h"
#include "Event.h"
void GameMode_Init(void) {
BlockID* inv = Inventory_Table;

View File

@ -3,7 +3,7 @@
#include "GraphicsEnums.h"
#include "Platform.h"
#include "Block.h"
#include "Events.h"
#include "Event.h"
#include "Funcs.h"
#include "ExtMath.h"

View File

@ -3,7 +3,7 @@
#include "Game.h"
#include "GraphicsCommon.h"
#include "GraphicsAPI.h"
#include "Events.h"
#include "Event.h"
#include "Drawer2D.h"
#include "ExtMath.h"

View File

@ -1,5 +1,5 @@
#include "Input.h"
#include "Events.h"
#include "Event.h"
#include "Funcs.h"
#include "Options.h"
@ -55,16 +55,16 @@ const UInt8* Key_Names[Key_Count] = {
};*/
bool Key_States[Key_Count];
bool Key_GetPressed(Key key) { return Key_States[key]; }
bool Key_IsPressed(Key key) { return Key_States[key]; }
void Key_SetPressed(Key key, bool pressed) {
if (Key_States[key] != pressed || Key_KeyRepeat) {
Key_States[key] = pressed;
if (pressed) {
Event_RaiseInt32(&KeyEvents_KeyDown, key);
Event_RaiseInt32(&KeyEvents_Down, key);
} else {
Event_RaiseInt32(&KeyEvents_KeyUp, key);
Event_RaiseInt32(&KeyEvents_Up, key);
}
}
}
@ -78,16 +78,16 @@ void Key_Clear(void) {
bool MouseButton_States[MouseButton_Count];
bool Mouse_GetPressed(MouseButton btn) { return MouseButton_States[btn]; }
bool Mouse_IsPressed(MouseButton btn) { return MouseButton_States[btn]; }
void Mouse_SetPressed(MouseButton btn, bool pressed) {
if (MouseButton_States[btn] != pressed) {
MouseButton_States[btn] = pressed;
if (pressed) {
Event_RaiseInt32(&MouseEvents_ButtonDown, btn);
Event_RaiseInt32(&MouseEvents_Down, btn);
} else {
Event_RaiseInt32(&MouseEvents_ButtonUp, btn);
Event_RaiseInt32(&MouseEvents_Up, btn);
}
}
}
@ -95,13 +95,13 @@ void Mouse_SetPressed(MouseButton btn, bool pressed) {
void Mouse_SetWheel(Real32 wheel) {
Real32 delta = wheel - Mouse_Wheel;
Mouse_Wheel = wheel;
Event_RaiseReal32(&MouseEvents_WheelChanged, delta);
Event_RaiseReal32(&MouseEvents_Wheel, delta);
}
void Mouse_SetPosition(Int32 x, Int32 y) {
Int32 deltaX = x - Mouse_X, deltaY = y - Mouse_Y;
Mouse_X = x; Mouse_Y = y;
Event_RaiseMouseMove(&MouseEvents_Move, deltaX, deltaY);
Event_RaiseMouseMove(&MouseEvents_Moved, deltaX, deltaY);
}
Key KeyBind_Keys[KeyBind_Count];
@ -130,7 +130,7 @@ const UInt8* KeyBind_Names[KeyBind_Count] = {
Key KeyBind_Get(KeyBind binding) { return KeyBind_Keys[binding]; }
Key KeyBind_GetDefault(KeyBind binding) { return KeyBind_Defaults[binding]; }
bool KeyBind_GetPressed(KeyBind binding) { return Key_States[KeyBind_Keys[binding]]; }
bool KeyBind_IsPressed(KeyBind binding) { return Key_States[KeyBind_Keys[binding]]; }
#define KeyBind_MakeName(name) String_Clear(&name); String_AppendConst(&name, "key-"); String_AppendConst(&name, KeyBind_Names[i]);

View File

@ -31,98 +31,66 @@
*/
typedef enum Key_ {
/* Key outside the known keys */
Key_Unknown,
Key_Unknown, /* Key outside the known keys */
/* Modifiers */
Key_ShiftLeft, Key_ShiftRight, Key_ControlLeft, Key_ControlRight,
Key_AltLeft, Key_AltRight, Key_WinLeft, Key_WinRight, Key_Menu,
/* Function keys (hopefully enough for most keyboards - mine has 26)
/ <keysymdef.h> on X11 reports up to 35 function keys. */
Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10,
Key_F11, Key_F12, Key_F13, Key_F14, Key_F15, Key_F16, Key_F17, Key_F18, Key_F19, Key_F20,
Key_F21, Key_F22, Key_F23, Key_F24, Key_F25, Key_F26, Key_F27, Key_F28, Key_F29, Key_F30,
Key_F31, Key_F32, Key_F33, Key_F34, Key_F35,
/* Direction arrows */
Key_Up, Key_Down, Key_Left, Key_Right,
/* Action keys */
Key_Enter, Key_Escape, Key_Space, Key_Tab, Key_BackSpace, Key_Insert,
Key_Delete, Key_PageUp, Key_PageDown, Key_Home, Key_End, Key_CapsLock,
Key_ScrollLock, Key_PrintScreen, Key_Pause, Key_NumLock,
/* Keypad keys */
Key_Keypad0, Key_Keypad1, Key_Keypad2, Key_Keypad3, Key_Keypad4,
Key_Keypad5, Key_Keypad6, Key_Keypad7, Key_Keypad8, Key_Keypad9,
Key_KeypadDivide, Key_KeypadMultiply, Key_KeypadSubtract,
Key_KeypadAdd, Key_KeypadDecimal, Key_KeypadEnter,
/* Letters */
Key_A, Key_B, Key_C, Key_D, Key_E, Key_F, Key_G, Key_H, Key_I, Key_J,
Key_K, Key_L, Key_M, Key_N, Key_O, Key_P, Key_Q, Key_R, Key_S, Key_T,
Key_U, Key_V, Key_W, Key_X, Key_Y, Key_Z,
/* Numbers */
Key_0, Key_1, Key_2, Key_3, Key_4,
Key_5, Key_6, Key_7, Key_8, Key_9,
/* Symbols */
Key_Tilde, Key_Minus, Key_Plus, Key_BracketLeft, Key_BracketRight,
Key_Semicolon, Key_Quote, Key_Comma, Key_Period, Key_Slash, Key_BackSlash,
Key_Count,
} Key;
/* Gets whether the given key is currently being pressed. */
bool Key_GetPressed(Key key);
/* Sets whether the given key is currently being pressed. */
void Key_SetPressed(Key key, bool pressed);
#define Key_IsAltPressed() (Key_GetPressed(Key_AltLeft) || Key_GetPressed(Key_AltRight))
#define Key_IsControlPressed() (Key_GetPressed(Key_ControlLeft) || Key_GetPressed(Key_ControlRight))
#define Key_IsShiftPressed() (Key_GetPressed(Key_ShiftLeft) || Key_GetPressed(Key_ShiftRight))
#define Key_IsWinPressed() (Key_GetPressed(Key_WinLeft) || Key_GetPressed(Key_WinRight))
/* Gets whether key repeating is on or not. If on (desirable for text input), multiple KeyDowns (varies by OS)
are generated for the same key when it is held down for a period of time. Should be off for game input. */
bool Key_KeyRepeat;
/* Names for each key. */
extern const UInt8* Key_Names[Key_Count];
/* Unpresses all keys that were previously pressed. */
#define Key_IsAltPressed() (Key_IsPressed(Key_AltLeft) || Key_IsPressed(Key_AltRight))
#define Key_IsControlPressed() (Key_IsPressed(Key_ControlLeft) || Key_IsPressed(Key_ControlRight))
#define Key_IsShiftPressed() (Key_IsPressed(Key_ShiftLeft) || Key_IsPressed(Key_ShiftRight))
#define Key_IsWinPressed() (Key_IsPressed(Key_WinLeft) || Key_IsPressed(Key_WinRight))
bool Key_IsPressed(Key key);
void Key_SetPressed(Key key, bool pressed);
void Key_Clear(void);
typedef enum MouseButton_ {
/* The left mouse button. */
MouseButton_Left,
/* The right mouse button. */
MouseButton_Right,
/* The middle mouse button. */
MouseButton_Middle,
/* The first extra mouse button. */
MouseButton_Button1,
/* The second extra mouse button. */
MouseButton_Button2,
MouseButton_Left, MouseButton_Right, MouseButton_Middle,
MouseButton_Button1, MouseButton_Button2,
MouseButton_Count,
} MouseButton;
/* Gets whether the given mouse button is currently being pressed. */
bool Mouse_GetPressed(MouseButton btn);
/* Sets whether the given mouse button is currently being pressed. */
void Mouse_SetPressed(MouseButton btn, bool pressed);
/* Gets the current wheel value of the mouse. */
Real32 Mouse_Wheel;
/* Gets the current position of the mouse. */
Int32 Mouse_X, Mouse_Y;
/* Sets the current wheel value of the mouse. */
bool Mouse_IsPressed(MouseButton btn);
void Mouse_SetPressed(MouseButton btn, bool pressed);
void Mouse_SetWheel(Real32 wheel);
/* Sets the current position of the mouse. */
void Mouse_SetPosition(Int32 x, Int32 y);
@ -140,13 +108,9 @@ typedef enum KeyBind_ {
KeyBind_Count
} KeyBind;
/* Gets the keyboard key that the given binding maps to. */
Key KeyBind_Get(KeyBind binding);
/* Gets the default keyboard key that the given binding maps to. */
Key KeyBind_GetDefault(KeyBind binding);
/* Gets whether the keyboard key that the given maps to is currently pressed. */
bool KeyBind_GetPressed(KeyBind binding);
/* Sets the keyboard key that the given binding maps to. */
bool KeyBind_IsPressed(KeyBind binding);
void KeyBind_Set(KeyBind binding, Key key);
/* Initalises and loads key bindings. */
void KeyBind_Init(void);

View File

@ -2,7 +2,7 @@
#include "Funcs.h"
#include "Game.h"
#include "Block.h"
#include "Events.h"
#include "Event.h"
bool Inventory_CanChangeSelected(void) {
if (!Inventory_CanChangeHeldBlock) {

View File

@ -2,7 +2,7 @@
#define CC_WORLDLIGHTING_H
#include "Typedefs.h"
#include "PackedCol.h"
#include "Events.h"
#include "Event.h"
#include "GameStructs.h"
/* Manages lighting of blocks in the world.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -1,7 +1,7 @@
#include "ModelCache.h"
#include "GraphicsAPI.h"
#include "Game.h"
#include "Events.h"
#include "Event.h"
#include "ExtMath.h"
#include "IModel.h"
#include "String.h"

View File

@ -3,7 +3,7 @@
#include "World.h"
#include "Constants.h"
#include "Funcs.h"
#include "Events.h"
#include "Event.h"
#include "ExtMath.h"
#include "Block.h"
#include "Lighting.h"

View File

@ -5,7 +5,7 @@
#include "GraphicsEnums.h"
#include "GraphicsCommon.h"
#include "Game.h"
#include "Events.h"
#include "Event.h"
GfxResourceID pickedPos_vb;
PackedCol pickedPos_col;

View File

@ -1,7 +1,7 @@
#include "Screens.h"
#include "Widgets.h"
#include "Game.h"
#include "Events.h"
#include "Event.h"
#include "GraphicsCommon.h"
void Screen_FreeWidgets(Widget** widgets, UInt32 widgetsCount) {

View File

@ -5,7 +5,7 @@
#include "Chat.h"
#include "Block.h"
#include "Random.h"
#include "Events.h"
#include "Event.h"
#include "AsyncDownloader.h"
#include "Player.h"

View File

@ -1,10 +1,9 @@
#include "SkyboxRenderer.h"
#include "Camera.h"
#include "Events.h"
#include "Event.h"
#include "Game.h"
#include "GraphicsAPI.h"
#include "GraphicsEnums.h"
#include "Events.h"
#include "PackedCol.h"
#include "2DStructs.h"
#include "VertexStructs.h"

View File

@ -2,7 +2,7 @@
#define CC_SKYBOXRENDERER_H
#include "Typedefs.h"
#include "Stream.h"
#include "Events.h"
#include "Event.h"
#include "GameStructs.h"
/* Renders a skybox.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3

View File

@ -2,12 +2,11 @@
#include "Block.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Events.h"
#include "Event.h"
#include "Game.h"
#include "GraphicsAPI.h"
#include "GraphicsEnums.h"
#include "GraphicsCommon.h"
#include "Events.h"
#include "PackedCol.h"
#include "Platform.h"
#include "Vectors.h"

View File

@ -405,7 +405,7 @@ void HotbarWidget_Free(GuiElement* elem) { }
bool HotbarWidget_HandlesKeyDown(GuiElement* elem, Key key) {
if (key >= Key_1 && key <= Key_9) {
Int32 index = key - Key_1;
if (KeyBind_GetPressed(KeyBind_HotbarSwitching)) {
if (KeyBind_IsPressed(KeyBind_HotbarSwitching)) {
/* Pick from first to ninth row */
Inventory_SetOffset(index * INVENTORY_BLOCKS_PER_HOTBAR);
HotbarWidget* widget = (HotbarWidget*)elem;

View File

@ -2,7 +2,7 @@
#include <Windows.h>
#include "Platform.h"
#include "Input.h"
#include "Events.h"
#include "Event.h"
#include "String.h"
#define win_Style WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
@ -192,7 +192,7 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
new_focused_state = LOWORD(wParam) != 0;
if (new_focused_state != win_Focused) {
win_Focused = new_focused_state;
Event_RaiseVoid(&WindowEvents_OnFocusedChanged);
Event_RaiseVoid(&WindowEvents_FocusChanged);
}
break;
@ -211,7 +211,7 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
Point2D new_location = Point2D_Make(pos->x, pos->y);
if (!Point2D_Equals(Window_GetLocation(), new_location)) {
win_Bounds.X = pos->x; win_Bounds.Y = pos->y;
Event_RaiseVoid(&WindowEvents_OnMove);
Event_RaiseVoid(&WindowEvents_Moved);
}
Size2D new_size = Size2D_Make(pos->cx, pos->cy);
@ -227,7 +227,7 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
if (suppress_resize <= 0) {
Event_RaiseVoid(&WindowEvents_OnResize);
Event_RaiseVoid(&WindowEvents_Resized);
}
}
}
@ -254,14 +254,14 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
if (new_state != win_State) {
win_State = new_state;
Event_RaiseVoid(&WindowEvents_OnWindowStateChanged);
Event_RaiseVoid(&WindowEvents_WindowStateChanged);
}
break;
case WM_CHAR:
keyChar = Convert_UnicodeToCP437((UInt16)wParam);
Event_RaiseInt32(&KeyEvents_KeyPress, keyChar);
Event_RaiseInt32(&KeyEvents_Press, keyChar);
break;
case WM_MOUSEMOVE:
@ -273,14 +273,14 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
/* Once we receive a mouse move event, it means that the mouse has re-entered the window. */
mouse_outside_window = false;
Window_EnableMouseTracking();
Event_RaiseVoid(&WindowEvents_OnMouseEnter);
Event_RaiseVoid(&WindowEvents_MouseEnter);
}
break;
case WM_MOUSELEAVE:
mouse_outside_window = true;
/* Mouse tracking is disabled automatically by the OS */
Event_RaiseVoid(&WindowEvents_OnMouseLeave);
Event_RaiseVoid(&WindowEvents_MouseLeave);
/* Set all mouse buttons to off when user leaves window, prevents them being stuck down. */
for (btn = 0; btn < MouseButton_Count; btn++) {
@ -402,7 +402,7 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
break;
case WM_CLOSE:
Event_RaiseVoid(&WindowEvents_OnClosing);
Event_RaiseVoid(&WindowEvents_Closing);
Window_Destroy();
break;
@ -410,7 +410,7 @@ LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPAR
win_Exists = false;
UnregisterClassA(win_ClassName, win_Instance);
if (win_DC != NULL) ReleaseDC(win_Handle, win_DC);
Event_RaiseVoid(&WindowEvents_OnClosed);
Event_RaiseVoid(&WindowEvents_Closed);
break;
}
return DefWindowProcA(handle, message, wParam, lParam);

View File

@ -3,7 +3,7 @@
#include "ErrorHandler.h"
#include "String.h"
#include "Platform.h"
#include "Events.h"
#include "Event.h"
#include "Random.h"
#include "Block.h"
#include "Entity.h"