This commit is contained in:
Michael Fabain Dirks
2016-05-08 22:47:15 +02:00
parent 2b82733b4b
commit e77dfd17eb
42 changed files with 5660 additions and 5560 deletions
+54 -54
View File
@@ -1,55 +1,55 @@
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "DisplayEnumerator.h"
BOOL CALLBACK BU_DisplayEnumerator_Callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
DisplayEnumerator* displayEnumerator = (DisplayEnumerator*)dwData;
displayEnumerator->displays.push_back(RECT(*lprcMonitor));
return TRUE;
}
DLL_FUNCTION(DisplayEnumerator*) BU_DisplayEnumerator_Create() {
DisplayEnumerator* displayEnumerator = new DisplayEnumerator();
return displayEnumerator;
}
DLL_FUNCTION(void) BU_DisplayEnumerator_Destroy(DisplayEnumerator* displayEnumerator) {
delete displayEnumerator;
}
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Enumerate(DisplayEnumerator* displayEnumerator) {
EnumDisplayMonitors(NULL, NULL, BU_DisplayEnumerator_Callback, (LPARAM)displayEnumerator);
return displayEnumerator->displays.size();
}
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Count(DisplayEnumerator* displayEnumerator) {
return displayEnumerator->displays.size();
}
DLL_FUNCTION(void) BU_DisplayEnumerator_Retrieve(DisplayEnumerator* displayEnumerator, uint32_t index, PRECT display) {
// Retrieve the requested index.
auto iterator = displayEnumerator->displays.begin();
std::advance(iterator, index);
// Copy data.
display->left = iterator->left;
display->top = iterator->top;
display->right = iterator->right;
display->bottom = iterator->bottom;
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "DisplayEnumerator.h"
BOOL CALLBACK BU_DisplayEnumerator_Callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
DisplayEnumerator* displayEnumerator = (DisplayEnumerator*)dwData;
displayEnumerator->displays.push_back(RECT(*lprcMonitor));
return TRUE;
}
DLL_FUNCTION(DisplayEnumerator*) BU_DisplayEnumerator_Create() {
DisplayEnumerator* displayEnumerator = new DisplayEnumerator();
return displayEnumerator;
}
DLL_FUNCTION(void) BU_DisplayEnumerator_Destroy(DisplayEnumerator* displayEnumerator) {
delete displayEnumerator;
}
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Enumerate(DisplayEnumerator* displayEnumerator) {
EnumDisplayMonitors(NULL, NULL, BU_DisplayEnumerator_Callback, (LPARAM)displayEnumerator);
return displayEnumerator->displays.size();
}
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Count(DisplayEnumerator* displayEnumerator) {
return displayEnumerator->displays.size();
}
DLL_FUNCTION(void) BU_DisplayEnumerator_Retrieve(DisplayEnumerator* displayEnumerator, uint32_t index, LPRECT display) {
// Retrieve the requested index.
auto iterator = displayEnumerator->displays.begin();
std::advance(iterator, index);
// Copy data.
display->left = iterator->left;
display->top = iterator->top;
display->right = iterator->right;
display->bottom = iterator->bottom;
}
+33 -38
View File
@@ -1,38 +1,33 @@
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include <list>
struct DisplayEnumerator {
std::list<RECT> displays;
};
// Internal Callback
BOOL CALLBACK BU_DisplayEnumerator_Callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
// Exported functions.
DLL_FUNCTION(DisplayEnumerator*) BU_DisplayEnumerator_Create();
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Create=_BU_DisplayEnumerator_Create@0")
DLL_FUNCTION(void) BU_DisplayEnumerator_Destroy(DisplayEnumerator* displayEnumerator);
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Destroy=_BU_DisplayEnumerator_Destroy@4")
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Enumerate(DisplayEnumerator* displayEnumerator);
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Enumerate=_BU_DisplayEnumerator_Enumerate@4")
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Count(DisplayEnumerator* displayEnumerator);
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Count=_BU_DisplayEnumerator_Count@4")
DLL_FUNCTION(void) BU_DisplayEnumerator_Retrieve(DisplayEnumerator* displayEnumerator, uint32_t index, LPRECT display);
#pragma comment(linker, "/EXPORT:BU_DisplayEnumerator_Retrieve=_BU_DisplayEnumerator_Retrieve@12")
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include <list>
struct DisplayEnumerator {
std::list<RECT> displays;
};
// Internal Callback
BOOL CALLBACK BU_DisplayEnumerator_Callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
// Exported functions.
DLL_FUNCTION(DisplayEnumerator*) BU_DisplayEnumerator_Create();
DLL_FUNCTION(void) BU_DisplayEnumerator_Destroy(DisplayEnumerator* displayEnumerator);
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Enumerate(DisplayEnumerator* displayEnumerator);
DLL_FUNCTION(uint32_t) BU_DisplayEnumerator_Count(DisplayEnumerator* displayEnumerator);
DLL_FUNCTION(void) BU_DisplayEnumerator_Retrieve(DisplayEnumerator* displayEnumerator, uint32_t index, LPRECT display);
+126 -126
View File
@@ -1,126 +1,126 @@
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "IndexerV1.h"
void IndexerV1::mark(uint32_t index, bool used) {
uint8_t bit = index & 0x3F;
index = index >> 6;
this->indexes[index] ^= (!(uint64_t)used ^ this->indexes[index]) & (1ULL << bit);
}
bool IndexerV1::is(uint32_t index, bool used) {
uint8_t bit = index & 0x3F;
index = index >> 6;
return (!!(this->indexes[index] & (1ULL << bit)) == used);
}
uint32_t IndexerV1::get() {
bool hasFoundIndex = false;
uint32_t foundIndex = 0;
// Our search begins and ends at lastAssignedIndex.
for (uint32_t indexOffset = 0; indexOffset <= INDEXER_INDEXES; indexOffset++) {
uint32_t index = (lastAssignedIndex >> 6) + indexOffset;
uint8_t bit = 0;
uint64_t checkValue = this->indexes[index];
for (uint8_t bit = 0; bit < 64; bit++) {
if (this->is((index << 6) + bit, false)) {
hasFoundIndex = true;
foundIndex = (index << 6) + bit;
break;
}
}
}
if (hasFoundIndex) {
this->mark(foundIndex, true);
return foundIndex;
}
return FALSE;
}
uint32_t IndexerV1::count(bool used) {
uint32_t amount = 0;
for (uint32_t index = 0; index <= INDEXER_INDEXES; index++) {
uint8_t bit = 0;
uint64_t checkValue = this->indexes[index];
if (checkValue == !(uint64_t)!used) {
amount += 64;
} else {
for (uint8_t bit = 0; bit < 64; bit++) {
amount += this->is((index << 6) + bit, used);
}
}
}
return amount;
}
DLL_FUNCTION(IndexerV1*) BU_IndexerV1_Create() {
return new IndexerV1();
}
DLL_FUNCTION(void) BU_IndexerV1_Destroy(IndexerV1* indexer) {
delete indexer;
}
DLL_FUNCTION(void) BU_IndexerV1_Mark(IndexerV1* indexer, uint32_t index, uint32_t used) {
indexer->mark(index, used != 0);
}
DLL_FUNCTION(void) BU_IndexerV1_MarkFree(IndexerV1* indexer, uint32_t index) {
indexer->mark(index, false);
}
DLL_FUNCTION(void) BU_IndexerV1_MarkUsed(IndexerV1* indexer, uint32_t index) {
indexer->mark(index, true);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_Is(IndexerV1* indexer, uint32_t index, uint32_t used) {
return indexer->is(index, used != 0);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsFree(IndexerV1* indexer, uint32_t index) {
return indexer->is(index, false);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsUsed(IndexerV1* indexer, uint32_t index) {
return indexer->is(index, true);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_Get(IndexerV1* indexer) {
return indexer->get();
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_Count(IndexerV1* indexer, uint32_t used) {
return indexer->count(used != 0);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountFree(IndexerV1* indexer) {
return indexer->count(false);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountUsed(IndexerV1* indexer) {
return indexer->count(true);
}
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "IndexerV1.h"
void IndexerV1::mark(uint32_t index, bool used) {
uint8_t bit = index & 0x3F;
index = index >> 6;
this->indexes[index] ^= (!(uint64_t)used ^ this->indexes[index]) & (1ULL << bit);
}
bool IndexerV1::is(uint32_t index, bool used) {
uint8_t bit = index & 0x3F;
index = index >> 6;
return (!!(this->indexes[index] & (1ULL << bit)) == used);
}
uint32_t IndexerV1::get() {
bool hasFoundIndex = false;
uint32_t foundIndex = 0;
// Our search begins and ends at lastAssignedIndex.
for (uint32_t indexOffset = 0; indexOffset <= INDEXER_INDEXES; indexOffset++) {
uint32_t index = (lastAssignedIndex >> 6) + indexOffset;
uint8_t bit = 0;
uint64_t checkValue = this->indexes[index];
for (uint8_t bit = 0; bit < 64; bit++) {
if (this->is((index << 6) + bit, false)) {
hasFoundIndex = true;
foundIndex = (index << 6) + bit;
break;
}
}
}
if (hasFoundIndex) {
this->mark(foundIndex, true);
return foundIndex;
}
return FALSE;
}
uint32_t IndexerV1::count(bool used) {
uint32_t amount = 0;
for (uint32_t index = 0; index <= INDEXER_INDEXES; index++) {
uint8_t bit = 0;
uint64_t checkValue = this->indexes[index];
if (checkValue == !(uint64_t)!used) {
amount += 64;
} else {
for (uint8_t bit = 0; bit < 64; bit++) {
amount += this->is((index << 6) + bit, used);
}
}
}
return amount;
}
DLL_FUNCTION(IndexerV1*) BU_IndexerV1_Create() {
return new IndexerV1();
}
DLL_FUNCTION(void) BU_IndexerV1_Destroy(IndexerV1* indexer) {
delete indexer;
}
DLL_FUNCTION(void) BU_IndexerV1_Mark(IndexerV1* indexer, uint32_t index, uint32_t used) {
indexer->mark(index, used != 0);
}
DLL_FUNCTION(void) BU_IndexerV1_MarkFree(IndexerV1* indexer, uint32_t index) {
indexer->mark(index, false);
}
DLL_FUNCTION(void) BU_IndexerV1_MarkUsed(IndexerV1* indexer, uint32_t index) {
indexer->mark(index, true);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_Is(IndexerV1* indexer, uint32_t index, uint32_t used) {
return indexer->is(index, used != 0);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsFree(IndexerV1* indexer, uint32_t index) {
return indexer->is(index, false);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsUsed(IndexerV1* indexer, uint32_t index) {
return indexer->is(index, true);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_Get(IndexerV1* indexer) {
return indexer->get();
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_Count(IndexerV1* indexer, uint32_t used) {
return indexer->count(used != 0);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountFree(IndexerV1* indexer) {
return indexer->count(false);
}
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountUsed(IndexerV1* indexer) {
return indexer->count(true);
}
+61 -61
View File
@@ -1,61 +1,61 @@
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include <cstdlib>
#include <list>
#include "BlitzUtility.h"
// 67108864 = 2 ^ 32 / 64
#define INDEXER_INDEXES 67108864 //pow(2,32) / 64
/** Indexer structure helps with getting unique, unused Indexes (Ids).
* Doing this natively would be too slow, so I'm using a DLL for this.
*/
struct IndexerV1 {
uint64_t indexes[INDEXER_INDEXES];
uint32_t lastAssignedIndex;
void mark(uint32_t index, bool used);
bool is(uint32_t index, bool used);
uint32_t get();
uint32_t count(bool used);
};
DLL_FUNCTION(IndexerV1*) BU_IndexerV1_Create();
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Create=_BU_IndexerV1_Create@0")
DLL_FUNCTION(void) BU_IndexerV1_Destroy(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Destroy=_BU_IndexerV1_Destroy@4")
DLL_FUNCTION(void) BU_IndexerV1_Mark(IndexerV1* indexer, uint32_t used, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Mark=_BU_IndexerV1_Mark@12")
DLL_FUNCTION(void) BU_IndexerV1_MarkFree(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_MarkFree=_BU_IndexerV1_MarkFree@8")
DLL_FUNCTION(void) BU_IndexerV1_MarkUsed(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_MarkUsed=_BU_IndexerV1_MarkUsed@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_Is(IndexerV1* indexer, uint32_t index, uint32_t used);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Is=_BU_IndexerV1_Is@12")
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsFree(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_IsFree=_BU_IndexerV1_IsFree@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsUsed(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_IsUsed=_BU_IndexerV1_IsUsed@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_Get(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Get=_BU_IndexerV1_Get@4")
DLL_FUNCTION(uint32_t) BU_IndexerV1_Count(IndexerV1* indexer, uint32_t used);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Count=_BU_IndexerV1_Count@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountFree(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_CountFree=_BU_IndexerV1_CountFree@4")
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountUsed(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_CountUsed=_BU_IndexerV1_CountUsed@4")
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include <cstdlib>
#include <list>
#include "BlitzUtility.h"
// 67108864 = 2 ^ 32 / 64
#define INDEXER_INDEXES 67108864 //pow(2,32) / 64
/** Indexer structure helps with getting unique, unused Indexes (Ids).
* Doing this natively would be too slow, so I'm using a DLL for this.
*/
struct IndexerV1 {
uint64_t indexes[INDEXER_INDEXES];
uint32_t lastAssignedIndex;
void mark(uint32_t index, bool used);
bool is(uint32_t index, bool used);
uint32_t get();
uint32_t count(bool used);
};
DLL_FUNCTION(IndexerV1*) BU_IndexerV1_Create();
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Create=_BU_IndexerV1_Create@0")
DLL_FUNCTION(void) BU_IndexerV1_Destroy(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Destroy=_BU_IndexerV1_Destroy@4")
DLL_FUNCTION(void) BU_IndexerV1_Mark(IndexerV1* indexer, uint32_t used, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Mark=_BU_IndexerV1_Mark@12")
DLL_FUNCTION(void) BU_IndexerV1_MarkFree(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_MarkFree=_BU_IndexerV1_MarkFree@8")
DLL_FUNCTION(void) BU_IndexerV1_MarkUsed(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_MarkUsed=_BU_IndexerV1_MarkUsed@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_Is(IndexerV1* indexer, uint32_t index, uint32_t used);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Is=_BU_IndexerV1_Is@12")
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsFree(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_IsFree=_BU_IndexerV1_IsFree@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_IsUsed(IndexerV1* indexer, uint32_t index);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_IsUsed=_BU_IndexerV1_IsUsed@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_Get(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Get=_BU_IndexerV1_Get@4")
DLL_FUNCTION(uint32_t) BU_IndexerV1_Count(IndexerV1* indexer, uint32_t used);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_Count=_BU_IndexerV1_Count@8")
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountFree(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_CountFree=_BU_IndexerV1_CountFree@4")
DLL_FUNCTION(uint32_t) BU_IndexerV1_CountUsed(IndexerV1* indexer);
#pragma comment(linker, "/EXPORT:BU_IndexerV1_CountUsed=_BU_IndexerV1_CountUsed@4")
+182 -182
View File
@@ -1,182 +1,182 @@
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include "MassOp.h"
MassOp::MassOp(uint32_t length) : length(length) {
this->instructions = new MassOpInstruction[length];
}
MassOp::~MassOp() {
delete this->instructions;
}
DLL_FUNCTION(MassOp*) BU_MassOp_Create(uint32_t length) {
MassOp* myMassOp = new MassOp(length);
return myMassOp;
}
DLL_FUNCTION(void) BU_MassOp_Destroy(MassOp* massop) {
delete massop;
}
DLL_FUNCTION(void) BU_MassOp_Instruction(MassOp* massop, uint32_t index, MassOpType type, MassOpCode code, intptr_t leftOperand, intptr_t rightOperand, intptr_t result) {
massop->instructions[index].type = type;
massop->instructions[index].code = code;
massop->instructions[index].leftOperand = leftOperand;
massop->instructions[index].rightOperand = rightOperand;
massop->instructions[index].result = result;
}
DLL_FUNCTION(void) BU_MassOp_Run(MassOp* massop) {
for (uint32_t index = 0; index < massop->length; index++) {
MassOpInstruction* instr = &massop->instructions[index];
switch (instr->code) {
case GoTo:
index = instr->leftOperand;
break;
case SetOpCode:
massop->instructions[instr->leftOperand].code = instr->rightOperand;
break;
case CopyLeft:
if (instr->leftOperand != instr->rightOperand) {
switch (instr->result) {
case 0:
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].leftOperand;
break;
case 1:
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].leftOperand;
break;
case 2:
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].leftOperand;
break;
}
}
break;
case CopyRight:
if (instr->leftOperand != instr->rightOperand) {
switch (instr->result) {
case 0:
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].rightOperand;
break;
case 1:
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].rightOperand;
break;
case 2:
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].rightOperand;
break;
}
}
break;
case CopyOut:
if (instr->leftOperand != instr->rightOperand) {
switch (instr->result) {
case 0:
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].result;
break;
case 1:
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].result;
break;
case 2:
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].result;
break;
}
}
break;
case If:
if (instr->leftOperand != instr->rightOperand) {
if (massop->instructions[instr->leftOperand].result == massop->instructions[instr->rightOperand].result) {
index += instr->result;
}
}
break;
case IfValue:
if (instr->leftOperand != instr->rightOperand) {
if (massop->instructions[instr->rightOperand].result == instr->rightOperand) {
index += instr->result;
}
}
break;
default:
switch (instr->type) {
case Double:
switch (instr->code) {
case Create:
instr->result = (uint32_t) BU_Double_New();
break;
case Destroy:
BU_Double_Destroy((double_t*)instr->leftOperand);
break;
case Copy:
instr->result = (uint32_t) BU_Double_Copy((double_t*)instr->leftOperand);
break;
case Set:
BU_Double_Set((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Add:
BU_Double_Add((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Sub:
BU_Double_Sub((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Mul:
BU_Double_Mul((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Div:
BU_Double_Div((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Compare:
instr->result = BU_Double_Compare((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
}
break;
case Long:
switch (instr->code) {
case Create:
instr->result = (uint32_t) BU_Long_New();
break;
case Destroy:
BU_Long_Destroy((int64_t*)instr->leftOperand);
break;
case Copy:
instr->result = (uint32_t) BU_Long_Copy((int64_t*)instr->leftOperand);
break;
case Set:
BU_Long_Set((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Add:
BU_Long_Add((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Sub:
BU_Long_Sub((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Mul:
BU_Long_Mul((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Div:
BU_Long_Div((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Compare:
instr->result = BU_Long_Compare((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
}
break;
}
}
}
}
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include "MassOp.h"
MassOp::MassOp(uint32_t length) : length(length) {
this->instructions = new MassOpInstruction[length];
}
MassOp::~MassOp() {
delete this->instructions;
}
DLL_FUNCTION(MassOp*) BU_MassOp_Create(uint32_t length) {
MassOp* myMassOp = new MassOp(length);
return myMassOp;
}
DLL_FUNCTION(void) BU_MassOp_Destroy(MassOp* massop) {
delete massop;
}
DLL_FUNCTION(void) BU_MassOp_Instruction(MassOp* massop, uint32_t index, MassOpType type, MassOpCode code, intptr_t leftOperand, intptr_t rightOperand, intptr_t result) {
massop->instructions[index].type = type;
massop->instructions[index].code = code;
massop->instructions[index].leftOperand = leftOperand;
massop->instructions[index].rightOperand = rightOperand;
massop->instructions[index].result = result;
}
DLL_FUNCTION(void) BU_MassOp_Run(MassOp* massop) {
for (uint32_t index = 0; index < massop->length; index++) {
MassOpInstruction* instr = &massop->instructions[index];
switch (instr->code) {
case GoTo:
index = instr->leftOperand;
break;
case SetOpCode:
massop->instructions[instr->leftOperand].code = instr->rightOperand;
break;
case CopyLeft:
if (instr->leftOperand != instr->rightOperand) {
switch (instr->result) {
case 0:
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].leftOperand;
break;
case 1:
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].leftOperand;
break;
case 2:
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].leftOperand;
break;
}
}
break;
case CopyRight:
if (instr->leftOperand != instr->rightOperand) {
switch (instr->result) {
case 0:
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].rightOperand;
break;
case 1:
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].rightOperand;
break;
case 2:
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].rightOperand;
break;
}
}
break;
case CopyOut:
if (instr->leftOperand != instr->rightOperand) {
switch (instr->result) {
case 0:
massop->instructions[instr->rightOperand].leftOperand = massop->instructions[instr->leftOperand].result;
break;
case 1:
massop->instructions[instr->rightOperand].rightOperand = massop->instructions[instr->leftOperand].result;
break;
case 2:
massop->instructions[instr->rightOperand].result = massop->instructions[instr->leftOperand].result;
break;
}
}
break;
case If:
if (instr->leftOperand != instr->rightOperand) {
if (massop->instructions[instr->leftOperand].result == massop->instructions[instr->rightOperand].result) {
index += instr->result;
}
}
break;
case IfValue:
if (instr->leftOperand != instr->rightOperand) {
if (massop->instructions[instr->rightOperand].result == instr->rightOperand) {
index += instr->result;
}
}
break;
default:
switch (instr->type) {
case Double:
switch (instr->code) {
case Create:
instr->result = (uint32_t) BU_Double_New();
break;
case Destroy:
BU_Double_Destroy((double_t*)instr->leftOperand);
break;
case Copy:
instr->result = (uint32_t) BU_Double_Copy((double_t*)instr->leftOperand);
break;
case Set:
BU_Double_Set((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Add:
BU_Double_Add((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Sub:
BU_Double_Sub((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Mul:
BU_Double_Mul((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Div:
BU_Double_Div((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
case Compare:
instr->result = BU_Double_Compare((double_t*)instr->leftOperand, (double_t*)instr->rightOperand);
break;
}
break;
case Long:
switch (instr->code) {
case Create:
instr->result = (uint32_t) BU_Long_New();
break;
case Destroy:
BU_Long_Destroy((int64_t*)instr->leftOperand);
break;
case Copy:
instr->result = (uint32_t) BU_Long_Copy((int64_t*)instr->leftOperand);
break;
case Set:
BU_Long_Set((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Add:
BU_Long_Add((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Sub:
BU_Long_Sub((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Mul:
BU_Long_Mul((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Div:
BU_Long_Div((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
case Compare:
instr->result = BU_Long_Compare((int64_t*)instr->leftOperand, (int64_t*)instr->rightOperand);
break;
}
break;
}
}
}
}
+106 -106
View File
@@ -1,107 +1,107 @@
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include "Type\Double.h"
enum MassOpType {
Long = 0,
Double = 1,
Vector2 = 10,
Vector3 = 11,
};
enum MassOpCode {
Create = 0,
Destroy = 1,
Copy = 2,
TempCreate = 5,
TempCopy = 6,
TempCleanup = 7,
Set = 10,
Add = 11,
Sub = 12,
Mul = 13,
Div = 14,
Compare = 15,
// Special OPCodes (Control MassOp)
// Goto - Go to a specific intruction
// oper_l = target massop index
GoTo = 249,
// SetOpCode - Change OpCode at position
// oper_l = target massop index
// oper_r = new OpCode
SetOpCode = 250,
// CopyLeft - Copy oper_l to new MassOp instruction.
// oper_l = source massop index
// oper_r = target massop index
// out = target position (0/oper_l, 1/oper_r, 2/out)
CopyLeft = 251,
// CopyRight - Copy oper_r to new MassOp instruction.
// oper_l = source massop index
// oper_r = target massop index
// out = target position (0/oper_l, 1/oper_r, 2/out)
CopyRight = 252,
// CopyOut - Copy out to new MassOp instruction.
// oper_l = source massop index
// oper_r = target massop index
// out = target position (0/oper_l, 1/oper_r, 2/out)
CopyOut = 253,
// If - If the result of index oper_l is equal to index oper_r, skip out instructions.
// oper_l = source massop index
// oper_r = target massop index
// out = instructions to skip
If = 254,
// IfValue - If the result of index oper_l is equal to oper_r, skip out instructions.
// oper_l = source massop index
// oper_r = value to compare with
// out = instructions to skip
IfValue = 255
};
struct BlitzBank {
uint32_t identifier;
uint32_t address;
uint32_t size;
};
struct MassOpInstruction {
uint8_t type;
uint8_t code;
uint32_t leftOperand, rightOperand;
uint32_t result;
};
struct MassOp {
MassOp(uint32_t length);
~MassOp();
uint32_t length;
MassOpInstruction* instructions;
};
DLL_FUNCTION(MassOp*) BU_MassOp_Create(uint32_t length);
#pragma comment(linker, "/EXPORT:BU_MassOp_Create=_BU_MassOp_Create@4")
DLL_FUNCTION(void) BU_MassOp_Destroy(MassOp* massop);
#pragma comment(linker, "/EXPORT:BU_MassOp_Destroy=_BU_MassOp_Destroy@4")
DLL_FUNCTION(void) BU_MassOp_Instruction(MassOp* massop, uint32_t index, MassOpType type, MassOpCode code, intptr_t leftOperand, intptr_t rightOperand, intptr_t result);
#pragma comment(linker, "/EXPORT:BU_MassOp_Instruction=_BU_MassOp_Instruction@28")
DLL_FUNCTION(void) BU_MassOp_Run(MassOp* massop);
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include "Type\Double.h"
enum MassOpType {
Long = 0,
Double = 1,
Vector2 = 10,
Vector3 = 11,
};
enum MassOpCode {
Create = 0,
Destroy = 1,
Copy = 2,
TempCreate = 5,
TempCopy = 6,
TempCleanup = 7,
Set = 10,
Add = 11,
Sub = 12,
Mul = 13,
Div = 14,
Compare = 15,
// Special OPCodes (Control MassOp)
// Goto - Go to a specific intruction
// oper_l = target massop index
GoTo = 249,
// SetOpCode - Change OpCode at position
// oper_l = target massop index
// oper_r = new OpCode
SetOpCode = 250,
// CopyLeft - Copy oper_l to new MassOp instruction.
// oper_l = source massop index
// oper_r = target massop index
// out = target position (0/oper_l, 1/oper_r, 2/out)
CopyLeft = 251,
// CopyRight - Copy oper_r to new MassOp instruction.
// oper_l = source massop index
// oper_r = target massop index
// out = target position (0/oper_l, 1/oper_r, 2/out)
CopyRight = 252,
// CopyOut - Copy out to new MassOp instruction.
// oper_l = source massop index
// oper_r = target massop index
// out = target position (0/oper_l, 1/oper_r, 2/out)
CopyOut = 253,
// If - If the result of index oper_l is equal to index oper_r, skip out instructions.
// oper_l = source massop index
// oper_r = target massop index
// out = instructions to skip
If = 254,
// IfValue - If the result of index oper_l is equal to oper_r, skip out instructions.
// oper_l = source massop index
// oper_r = value to compare with
// out = instructions to skip
IfValue = 255
};
struct BlitzBank {
uint32_t identifier;
uint32_t address;
uint32_t size;
};
struct MassOpInstruction {
uint8_t type;
uint8_t code;
uint32_t leftOperand, rightOperand;
uint32_t result;
};
struct MassOp {
MassOp(uint32_t length);
~MassOp();
uint32_t length;
MassOpInstruction* instructions;
};
DLL_FUNCTION(MassOp*) BU_MassOp_Create(uint32_t length);
#pragma comment(linker, "/EXPORT:BU_MassOp_Create=_BU_MassOp_Create@4")
DLL_FUNCTION(void) BU_MassOp_Destroy(MassOp* massop);
#pragma comment(linker, "/EXPORT:BU_MassOp_Destroy=_BU_MassOp_Destroy@4")
DLL_FUNCTION(void) BU_MassOp_Instruction(MassOp* massop, uint32_t index, MassOpType type, MassOpCode code, intptr_t leftOperand, intptr_t rightOperand, intptr_t result);
#pragma comment(linker, "/EXPORT:BU_MassOp_Instruction=_BU_MassOp_Instruction@28")
DLL_FUNCTION(void) BU_MassOp_Run(MassOp* massop);
#pragma comment(linker, "/EXPORT:BU_MassOp_Run=_BU_MassOp_Run@4")
+118 -118
View File
@@ -1,118 +1,118 @@
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "WindowMessageHandler.h"
std::list<WindowUserData>* WindowMessageHandler_List;
void BU_WindowMessageHandler_OnProcessAttach() {
WindowMessageHandler_List = new std::list<WindowUserData>();
}
void BU_WindowMessageHandler_OnProcessDetach() {
for (auto iterator = WindowMessageHandler_List->begin(), end = WindowMessageHandler_List->end(); iterator != end; iterator++) {
BU_WindowMessageHandler_Uninstall(iterator->hwnd);
}
WindowMessageHandler_List->clear();
delete WindowMessageHandler_List;
}
LRESULT CALLBACK BU_WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
switch (uMsg) {
case WM_SIZE:
UserData->WindowWasResized = true;
UserData->WindowClientWidth = lParam & 0xFFFF;
UserData->WindowClientHeight = lParam & 0xFFFF0000 >> 16;
return CallWindowProc(UserData->oWindowProcedure, hwnd, uMsg, wParam, lParam);
break;
case WM_CLOSE:
UserData->DestroyCount++;
return false;
case WM_DESTROY:
UserData->CloseCount++;
return false;
default:
return CallWindowProc(UserData->oWindowProcedure, hwnd, uMsg, wParam, lParam);
}
} else {
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
DLL_FUNCTION(void) BU_WindowMessageHandler_Install(HWND hwnd)
{
WindowUserData* UserData = new WindowUserData;
ZeroMemory(UserData, sizeof(UserData));
UserData->oWindowProcedure = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)&BU_WindowMessageHandler_Procedure);
UserData->oUserData = SetWindowLong(hwnd, GWL_USERDATA, (LONG)UserData);
}
DLL_FUNCTION(void) BU_WindowMessageHandler_Uninstall(HWND hwnd)
{
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
SetWindowLong(hwnd, GWL_USERDATA, UserData->oUserData);
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)(UserData->oWindowProcedure));
delete UserData;
}
}
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point)
{
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
int toReturn = UserData->WindowWasResized;
point->x = UserData->WindowClientWidth;
point->y = UserData->WindowClientHeight;
UserData->WindowWasResized = false;
return toReturn;
}
return FALSE;
}
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Destroy(HWND hwnd)
{
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
int toReturn = UserData->DestroyCount;
UserData->DestroyCount = 0;
return toReturn;
}
return 0;
}
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Close(HWND hwnd)
{
if (hwnd) {
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
int toReturn = UserData->CloseCount;
UserData->CloseCount = 0;
return toReturn;
}
}
return 0;
}
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "WindowMessageHandler.h"
std::list<WindowUserData>* WindowMessageHandler_List;
void BU_WindowMessageHandler_OnProcessAttach() {
WindowMessageHandler_List = new std::list<WindowUserData>();
}
void BU_WindowMessageHandler_OnProcessDetach() {
for (auto iterator = WindowMessageHandler_List->begin(), end = WindowMessageHandler_List->end(); iterator != end; iterator++) {
BU_WindowMessageHandler_Uninstall(iterator->hwnd);
}
WindowMessageHandler_List->clear();
delete WindowMessageHandler_List;
}
LRESULT CALLBACK BU_WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
switch (uMsg) {
case WM_SIZE:
UserData->WindowWasResized = true;
UserData->WindowClientWidth = lParam & 0xFFFF;
UserData->WindowClientHeight = lParam & 0xFFFF0000 >> 16;
return CallWindowProc(UserData->oWindowProcedure, hwnd, uMsg, wParam, lParam);
break;
case WM_CLOSE:
UserData->DestroyCount++;
return false;
case WM_DESTROY:
UserData->CloseCount++;
return false;
default:
return CallWindowProc(UserData->oWindowProcedure, hwnd, uMsg, wParam, lParam);
}
} else {
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
DLL_FUNCTION(void) BU_WindowMessageHandler_Install(HWND hwnd)
{
WindowUserData* UserData = new WindowUserData;
ZeroMemory(UserData, sizeof(UserData));
UserData->oWindowProcedure = (WNDPROC)SetWindowLong(hwnd, GWL_WNDPROC, (LONG)&BU_WindowMessageHandler_Procedure);
UserData->oUserData = SetWindowLong(hwnd, GWL_USERDATA, (LONG)UserData);
}
DLL_FUNCTION(void) BU_WindowMessageHandler_Uninstall(HWND hwnd)
{
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
SetWindowLong(hwnd, GWL_USERDATA, UserData->oUserData);
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)(UserData->oWindowProcedure));
delete UserData;
}
}
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point)
{
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
int toReturn = UserData->WindowWasResized;
point->x = UserData->WindowClientWidth;
point->y = UserData->WindowClientHeight;
UserData->WindowWasResized = false;
return toReturn;
}
return FALSE;
}
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Destroy(HWND hwnd)
{
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
int toReturn = UserData->DestroyCount;
UserData->DestroyCount = 0;
return toReturn;
}
return 0;
}
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Close(HWND hwnd)
{
if (hwnd) {
WindowUserData* UserData = (WindowUserData*)GetWindowLong(hwnd, GWL_USERDATA);
if (UserData) {
int toReturn = UserData->CloseCount;
UserData->CloseCount = 0;
return toReturn;
}
}
return 0;
}
+48 -48
View File
@@ -1,49 +1,49 @@
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include <list>
struct WindowUserData {
HWND hwnd;
WNDPROC oWindowProcedure;
LONG oUserData;
// WM_SIZE
bool WindowWasResized;
uint32_t WindowClientWidth, WindowClientHeight;
// WM_DESTROY, WM_CLOSE
uint32_t DestroyCount, CloseCount;
};
void BU_WindowMessageHandler_OnProcessAttach();
void BU_WindowMessageHandler_OnProcessDetach();
LRESULT CALLBACK BU_WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DLL_FUNCTION(void) BU_WindowMessageHandler_Install(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Install=_BU_WindowMessageHandler_Install@4")
DLL_FUNCTION(void) BU_WindowMessageHandler_Uninstall(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Uninstall=_BU_WindowMessageHandler_Uninstall@4")
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Resize=_BU_WindowMessageHandler_Message_Resize@8")
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Destroy(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Destroy=_BU_WindowMessageHandler_Message_Destroy@4")
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Close(HWND hwnd);
// BlitzUtility - Expanding the normal Blitz functionality.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 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 Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include <list>
struct WindowUserData {
HWND hwnd;
WNDPROC oWindowProcedure;
LONG oUserData;
// WM_SIZE
bool WindowWasResized;
uint32_t WindowClientWidth, WindowClientHeight;
// WM_DESTROY, WM_CLOSE
uint32_t DestroyCount, CloseCount;
};
void BU_WindowMessageHandler_OnProcessAttach();
void BU_WindowMessageHandler_OnProcessDetach();
LRESULT CALLBACK BU_WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
DLL_FUNCTION(void) BU_WindowMessageHandler_Install(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Install=_BU_WindowMessageHandler_Install@4")
DLL_FUNCTION(void) BU_WindowMessageHandler_Uninstall(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Uninstall=_BU_WindowMessageHandler_Uninstall@4")
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Resize=_BU_WindowMessageHandler_Message_Resize@8")
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Destroy(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Destroy=_BU_WindowMessageHandler_Message_Destroy@4")
DLL_FUNCTION(uint32_t) BU_WindowMessageHandler_Message_Close(HWND hwnd);
#pragma comment(linker, "/EXPORT:BU_WindowMessageHandler_Message_Close=_BU_WindowMessageHandler_Message_Close@4")