Skip to content

Commit

Permalink
fix: 修复 #149 引入的使用 MSVC 编译时控制台无法使用的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yixy-only committed Apr 24, 2024
1 parent 176658e commit 8aa52d3
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 33 deletions.
1 change: 1 addition & 0 deletions src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "ege_head.h"
#include "ege_common.h"
#include <math.h>

namespace ege
Expand Down
2 changes: 1 addition & 1 deletion src/compress.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ege_api.h"
#include "ege_head.h"
#include <zlib.h>

namespace ege
Expand Down
1 change: 1 addition & 0 deletions src/debug.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "debug.h"

#include "ege_head.h"
#include "ege_common.h"

#include <Windows.h>

Expand Down
3 changes: 0 additions & 3 deletions src/ege_api.h

This file was deleted.

1 change: 1 addition & 0 deletions src/ege_extension.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "ege_head.h"
#include "../include/ege/egecontrolbase.h"
#include "../include/ege/button.h"
#include "../include/ege/fps.h"
Expand Down
2 changes: 0 additions & 2 deletions src/ege_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@
#endif

#include "thread_queue.h"
#include "ege_api.h"
#include "ege_common.h"

#ifndef ERROR_SUCCESS
#define ERROR_SUCCESS 0
Expand Down
2 changes: 2 additions & 0 deletions src/egegapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
#include <cstdio>

#include "ege_head.h"
#include "ege_common.h"
#include "ege_extension.h"



#include <stdio.h>

namespace ege
Expand Down
10 changes: 5 additions & 5 deletions src/encodeconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
*/

#include "encodeconv.h"
#include <ege.h>
#include "ege_head.h"

#include <Windows.h>

namespace ege
{

/**
* @brief 将宽字符串转为多字节(ANSI)字符串
* @brief 将宽字符串转为多字节字符串(多字节字符编码由 setcodepage 确定)
*
* @param wStr 以终止字符结尾的宽字符串
* @return std::string 转换后的字符串(ANSI)
* @return std::string 转换后的字符串
*/
std::string w2mb(const wchar_t wStr[])
{
Expand All @@ -27,9 +27,9 @@ std::string w2mb(const wchar_t wStr[])
}

/**
* @brief 将多字节(ANSI)字符串转为宽字符串
* @brief 将多字节字符串转为宽字符串(多字节字符编码由 setcodepage 确定)
*
* @param mbStr 以终止字符结尾的多字节(ANSI)字符串
* @param mbStr 以终止字符结尾的多字节字符串
* @return std::wstring 转换后的宽字符
*/
std::wstring mb2w(const char mbStr[])
Expand Down
1 change: 1 addition & 0 deletions src/font.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "font.h"

#include "ege_head.h"
#include "ege_common.h"

namespace ege
{
Expand Down
1 change: 1 addition & 0 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <stdlib.h>

#include "ege_head.h"
#include "ege_common.h"
#include "ege_extension.h"

#ifdef _ITERATOR_DEBUG_LEVEL
Expand Down
1 change: 1 addition & 0 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#endif

#include "ege_head.h"
#include "ege_common.h"

// #ifdef _ITERATOR_DEBUG_LEVEL
// #undef _ITERATOR_DEBUG_LEVEL
Expand Down
1 change: 1 addition & 0 deletions src/keyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ege_head.h"
#include "ege_common.h"

namespace ege
{
Expand Down
4 changes: 2 additions & 2 deletions src/message.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "message.h"

#include "ege_head.h"

#include "message.h"

namespace ege
{

Expand Down
1 change: 1 addition & 0 deletions src/mouse.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mouse.h"

#include "ege_head.h"
#include "ege_common.h"

namespace ege
{
Expand Down
3 changes: 3 additions & 0 deletions src/music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ filename music.cpp
MUSIC类的定义
*/

#include "music.h"

#include "ege_head.h"
#include "ege_common.h"
#include "mmsystem.h"

#ifndef MUSIC_ASSERT_TRUE
Expand Down
39 changes: 20 additions & 19 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include "ege_head.h"

#include <time.h>

namespace ege
Expand Down Expand Up @@ -45,9 +46,9 @@ class mtrandom
public:
mtrandom() : left(1) { init(); }

explicit mtrandom(uint32 seed) : left(1) { init(seed); }
explicit mtrandom(uint32_t seed) : left(1) { init(seed); }

mtrandom(uint32* init_key, int key_length) : left(1)
mtrandom(uint32_t* init_key, int key_length) : left(1)
{
int i = 1, j = 0;
int k = N > key_length ? N : key_length;
Expand Down Expand Up @@ -79,15 +80,15 @@ class mtrandom
state[0] = 2147483648UL; // MSB is 1; assuring non-zero initial array
}

void reset(uint32 rs)
void reset(uint32_t rs)
{
init(rs);
next_state();
}

uint32 rand()
uint32_t rand()
{
uint32 y;
uint32_t y;
if (0 == --left) {
next_state();
}
Expand All @@ -105,12 +106,12 @@ class mtrandom
// generates a random number on [0,1) with 53-bit resolution
double res53()
{
uint32 a = rand() >> 5, b = rand() >> 6;
uint32_t a = rand() >> 5, b = rand() >> 6;
return (a * 67108864.0 + b) / 9007199254740992.0;
}

private:
void init(uint32 seed = 19650218UL)
void init(uint32_t seed = 19650218UL)
{
state[0] = seed & 4294967295UL;
for (int j = 1; j < N; ++j) {
Expand All @@ -125,7 +126,7 @@ class mtrandom

void next_state()
{
uint32* p = state;
uint32_t* p = state;
int i;

for (i = N - M + 1; --i; ++p) {
Expand All @@ -140,13 +141,13 @@ class mtrandom
next = state;
}

uint32 mixbits(uint32 u, uint32 v) const { return (u & 2147483648UL) | (v & 2147483647UL); }
uint32_t mixbits(uint32_t u, uint32_t v) const { return (u & 2147483648UL) | (v & 2147483647UL); }

uint32 twist(uint32 u, uint32 v) const { return ((mixbits(u, v) >> 1) ^ (v & 1UL ? 2567483615UL : 0UL)); }
uint32_t twist(uint32_t u, uint32_t v) const { return ((mixbits(u, v) >> 1) ^ (v & 1UL ? 2567483615UL : 0UL)); }

uint32 state[N];
uint32 left;
uint32* next;
uint32_t state[N];
uint32_t left;
uint32_t* next;
};

#undef N
Expand All @@ -159,21 +160,21 @@ class mtrand_help
public:
mtrand_help() {}

void operator()(uint32 s) { r.reset(s); }
void operator()(uint32_t s) { r.reset(s); }

uint32 operator()() const { return r.rand(); }
uint32_t operator()() const { return r.rand(); }

double operator()(double) { return r.real(); }
};

mtrandom mtrand_help::r;

extern void mtsrand(uint32 s)
extern void mtsrand(uint32_t s)
{
mtrand_help()(s);
}

extern uint32 mtirand()
extern uint32_t mtirand()
{
return mtrand_help()();
}
Expand All @@ -185,8 +186,8 @@ extern double mtdrand()

void randomize()
{
static uint32 add = 0;
mtsrand((uint32)time(NULL) + add++);
static uint32_t add = 0;
mtsrand((uint32_t)time(NULL) + add++);
}

unsigned int random(unsigned int n)
Expand Down
1 change: 1 addition & 0 deletions src/time.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ege_head.h"
#include "ege_common.h"
#include "ege_extension.h"

namespace ege
Expand Down
4 changes: 3 additions & 1 deletion src/window.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "window.h"

#include "ege_head.h"
#include "ege_common.h"

#define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_CLIPCHILDREN)

#define EXSTYLE_
namespace ege
{

Expand Down

0 comments on commit 8aa52d3

Please sign in to comment.