Commit 27e1fd92 authored by nanahira's avatar nanahira

Merge branch 'server' into full-view

parents 52c11e57 bb1a5baf
......@@ -36,13 +36,13 @@ mat_linux:
- linux
script:
- apt update; apt -y install git wget tar
#- git clone --depth=1 https://code.mycard.moe/mycard/irrlicht irrlicht_linux
# - git clone --depth=1 https://code.mycard.moe/mycard/irrlicht-new irrlicht
- wget -O - https://cdn01.moecube.com/ygopro-build-materials/premake-5.0.0-alpha14-linux.tar.gz | tar zfx -
- env PROCESSOR_COUNT=$(nproc) ./.ci/libevent-prebuild.sh
artifacts:
paths:
- premake5
#- irrlicht_linux
#- irrlicht
- libevent-stable
mat_windows:
......@@ -83,7 +83,6 @@ exec_windows:
script:
- git submodule update --init
- bash -c 'cp -rf premake/* .'
#- cmd /C "patch -p0 < irrlicht\irrlicht.patch"
- '.\premake5.exe vs2019'
- cmd /c '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" build\ygo.sln /m /p:Configuration=Release'
- copy bin\release\ygopro.exe .
......
......@@ -2,6 +2,7 @@
#define BASE64_H
#include <string>
#include <cstring>
const char kBase64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
......@@ -60,8 +61,10 @@ class Base64 {
size_t encoded_length = EncodedLength(input_length);
if (out_length < encoded_length) return false;
if (out_length < encoded_length + 1) return false;
std::memset(out, 0, out_length);
while (input_length--) {
a3[i++] = *input++;
if (i == 3) {
......
......@@ -353,7 +353,7 @@ int DeckManager::TypeCount(std::vector<code_pointer> list, unsigned int ctype) {
bool DeckManager::LoadDeckFromCode(Deck& deck, const char *code, int len) {
char data[1024], *pdeck = data, *data_ = data;
int decoded_len = Base64::DecodedLength(code, len);
if(decoded_len < 8 || !Base64::Decode(code, len, data_, decoded_len))
if(decoded_len > 1024 || decoded_len < 8 || !Base64::Decode(code, len, data_, decoded_len))
return false;
int mainc = BufferIO::ReadInt32(pdeck);
int sidec = BufferIO::ReadInt32(pdeck);
......@@ -372,7 +372,7 @@ int DeckManager::SaveDeckToCode(Deck& deck, char* code) {
BufferIO::WriteInt32(pdeck, deck.side[i]->first);
int len = pdeck - deckbuf;
int encoded_len = Base64::EncodedLength(len);
Base64::Encode(deckbuf, len, code, encoded_len);
Base64::Encode(deckbuf, len, code, encoded_len+1);
return encoded_len;
}
bool DeckManager::CreateCategory(const wchar_t* name) {
......
#[2021.10][2021.10 TCG][2021.7][2021.4][2021.1][2020.10][2020.7][2020.4][2020.1][2019.10][2019.7][2019.4][2019.1][2018.10][2018.7][2018.4][2018.1][2017.10][2017.7][2017.4][2017.1][2016.10][2016.7][2016.4][2016.1][2015.10][2015.4][2015.1][2014.10][2014.7][2014.4][2014.2][2013.9][2021.7 TCG][2021.3 TCG][2020.12 TCG][2020.9 TCG][2020.6 TCG][2020.4 TCG][2020.1 TCG][2019.10 TCG][2019.7 TCG][2019.4 TCG][2019.1 TCG][2018.12 TCG][2018.9 TCG][2018.5 TCG][2018.2 TCG][2017.11 TCG][2017.9 TCG][2017.6 TCG][2017.3 TCG][2016.8 TCG][2016.4 TCG][2015.11 TCG][2015.7 TCG][2015.4 TCG][2015.1 TCG][2014.10 TCG][2014.7 TCG][2014.4 TCG][2014.1.1 TCG][2013.10.11 TCG][2013.3.1][2012.9.1][2012.3.1][2011.9.1]
#[2022.1][2021.10][2021.10 TCG][2021.7][2021.4][2021.1][2020.10][2020.7][2020.4][2020.1][2019.10][2019.7][2019.4][2019.1][2018.10][2018.7][2018.4][2018.1][2017.10][2017.7][2017.4][2017.1][2016.10][2016.7][2016.4][2016.1][2015.10][2015.4][2015.1][2014.10][2014.7][2014.4][2014.2][2013.9][2021.7 TCG][2021.3 TCG][2020.12 TCG][2020.9 TCG][2020.6 TCG][2020.4 TCG][2020.1 TCG][2019.10 TCG][2019.7 TCG][2019.4 TCG][2019.1 TCG][2018.12 TCG][2018.9 TCG][2018.5 TCG][2018.2 TCG][2017.11 TCG][2017.9 TCG][2017.6 TCG][2017.3 TCG][2016.8 TCG][2016.4 TCG][2015.11 TCG][2015.7 TCG][2015.4 TCG][2015.1 TCG][2014.10 TCG][2014.7 TCG][2014.4 TCG][2014.1.1 TCG][2013.10.11 TCG][2013.3.1][2012.9.1][2012.3.1][2011.9.1]
!2022.1
#forbidden
91869203 0 --アマゾネスの射手
20663556 0 --イレカエル
44910027 0 --ヴィクトリー・ドラゴン
51858306 0 --エクリプス・ワイバーン
25862681 0 --エンシェント・フェアリー・ドラゴン
53804307 0 --焔征竜-ブラスター
07563579 0 --Emヒグルミ
17330916 0 --EMモンキーボード
34945480 0 --外神アザトート
90411554 0 --巌征竜-レドックス
08903700 0 --儀式魔人リリーサー
11384280 0 --キャノン・ソルジャー
17412721 0 --旧神ノーデン
67441435 0 --グローアップ・バルブ
34124316 0 --サイバーポッド
88071625 0 --The tyrant NEPTUNE
61665245 0 --サモン・ソーサレス
52653092 0 --SNo.0 ホープ・ゼアル
48905153 0 --十二獣ドランシア
85115440 0 --十二獣ブルホーン
59537380 0 --守護竜アガーペイン
86148577 0 --守護竜エルピィ
88581108 0 --真竜皇V.F.D.
21377582 0 --真竜剣皇マスターP
94677445 0 --星杯の神子イヴ
16923472 0 --ゼンマイハンター
15341821 0 --ダンディライオン
37818794 0 --超魔導竜騎士-ドラグーン・オブ・レッドアイズ
18326736 0 --星守の騎士 プトレマイオス
79875176 0 --トゥーン・キャノン・ソルジャー
75732622 0 --トーチ・ゴーレム
22593417 0 --トポロジック・ガンブラー・ドラゴン
39064822 0 --トロイメア・ゴブリン
03679218 0 --トロイメア・マーメイド
54719828 0 --No.16 色の支配者ショック・ルーラー
58820923 0 --No.95 ギャラクシーアイズ・ダークマター・ドラゴン
26400609 0 --瀑征竜-タイダル
71525232 0 --破滅竜ガンドラX
78706415 0 --ファイバーポッド
93369354 0 --フィッシュボーグ-ガンナー
23558733 0 --フェニキシアン・クラスター・アマリリス
09929398 0 --BF-朧影のゴウフウ
09047460 0 --BF-隠れ蓑のスチーム
31178212 0 --マジェスペクター・ユニコーン
63101919 0 --マジックテンペスター
34206604 0 --魔導サイエンティスト
04423206 0 --M.X-セイバー インヴォーカー
14702066 0 --メガキャノン・ソルジャー
96782886 0 --メンタルマスター
03078576 0 --八汰烏
34086406 0 --ラヴァルバル・チェイン
85243784 0 --リンクロス
57421866 0 --レベル・スティーラー
41482598 0 --悪夢の蜃気楼
44763025 0 --いたずら好きな双子悪魔
17375316 0 --押収
19613556 0 --大嵐
74191942 0 --苦渋の選択
42829885 0 --強引な番兵
45986603 0 --強奪
55144522 0 --強欲な壺
04031928 0 --心変わり
23557835 0 --次元融合
31423101 0 --神剣-フェニックスブレード
57953380 0 --生還の宝札
54447022 0 --ソウル・チャージ
60682203 0 --大寒波
69243953 0 --蝶の短剣-エルマ
79571449 0 --天使の施し
70828912 0 --早すぎた埋葬
42703248 0 --ハリケーン
76375976 0 --魔鍾洞
52947044 0 --フュージョン・デステニー
34906152 0 --マスドライバー
46448938 0 --魔導書の神判
46411259 0 --突然変異
85602018 0 --遺言状
27174286 0 --異次元からの帰還
93016201 0 --王宮の弾圧
03280747 0 --第六感
64697231 0 --ダスト・シュート
80604091 0 --血の代償
35316708 0 --刻の封印
32723153 0 --マジカル・エクスプロージョン
17178486 0 --ライフチェンジャー
28566710 0 --ラストバトル!
#limit
25538345 1 --幻影骑士団ティアースケイル
25725326 1 --プランキッズ・ミュー
64034255 1 --A・ジェネクス・バードマン
76794549 1 --アストログラフ・マジシャン
01561110 1 --ABC-ドラゴン・バスター
30741503 1 --オルフェゴール・ガラテア
57835716 1 --オルフェゴール・ディヴェル
50588353 1 --水晶機巧-ハリファイバー
12289247 1 --クロノグラフ・マジシャン
49684352 1 --虹彩の魔術師
38814750 1 --PSYフレームギア・γ
74586817 1 --PSYフレームロード・Ω
26889158 1 --転生炎獣ガゼル
74997493 1 --鎖龍蛇-スカルデット
69811710 1 --宵星の騎士ギルス
78872731 1 --十二獣モルモラット
06602300 1 --重爆撃禽 ボム・フェネクス
28985331 1 --終末の騎士
78080961 1 --SPYRAL-ジーニアス
81275020 1 --SRベイゴマックス
63288573 1 --閃刀姫-カガリ
81122844 1 --発条空母ゼンマイティ
82385847 1 --ダイナレスラー・パンクラトプス
73941492 1 --調弦の魔術師
15291624 1 --超雷龍-サンダー・ドラゴン
90953320 1 --TG ハイパー・ライブラリアン
69015963 1 --デビル・フランケン
16226786 1 --深淵の暗殺者
90448279 1 --天霆號アーゼウス
69610326 1 --覇王眷竜ダークヴルム
52687916 1 --氷結界の龍 トリシューラ
33396948 1 --封印されしエクゾディア
44519536 1 --封印されし者の左足
07902349 1 --封印されし者の左腕
08124921 1 --封印されし者の右足
70903634 1 --封印されし者の右腕
70369116 1 --捕食植物ヴェルテ・アナコンダ
35272499 1 --捕食植物オフリス・スコーピオ
24094258 1 --ヘビーメタルフォーゼ・エレクトラム
33508719 1 --メタモルポット
90809975 1 --餅カエル
83107873 1 --雷鳥龍-サンダー・ドラゴン
89399912 1 --嵐征竜-テンペスト
92746535 1 --竜剣士ラスターP
33782437 1 --一時休戦
01845204 1 --簡易融合
66957584 1 --インフェルニティガン
81439173 1 --おろかな埋葬
73680966 1 --終わりの始まり
23701465 1 --原初の種
12580477 1 --サンダー・ボルト
83764718 1 --死者蘇生
46060017 1 --十二獣の会局
52340444 1 --閃刀機-ホーネットビット
32807846 1 --増援
72892473 1 --手札抹殺
73628505 1 --テラ・フォーミング
01984618 1 --天底の使徒
13035077 1 --ドラゴニックD
35371948 1 --トリックスター・ライトステージ
18144506 1 --ハーピィの羽根帚
65681983 1 --抹殺の指名者
75500286 1 --封印の黄金櫃
07394770 1 --ブリリアント・フュージョン
73468603 1 --盆回し
93600443 1 --マスク・チェンジ・セカンド
15854426 1 --霞の谷の神風
27970830 1 --六武の門
02295440 1 --ワン・フォー・ワン
05851097 1 --虚無空間
61740673 1 --王宮の勅命
21076084 1 --トリックスター・リンカーネイション
23002292 1 --レッド・リブート
#semi limit
42790071 2 --オルターガイスト・マルチフェイカー
30680659 2 --聖殿の水遣い
09411399 2 --D-HERO ディアボリックガイ
43694650 2 --未界域のジャッカロープ
29596581 2 --雷獣龍-サンダー・ドラゴン
48686504 2 --ローンファイア・ブロッサム
57103969 2 --炎舞-「天璣」
56465981 2 --龍相剣現
84731222 2 --希望の記憶
67723438 2 --緊急テレポート
35261759 2 --強欲で貪欲な壺
54631665 2 --SPYRAL RESORT
98338152 2 --閃刀機-ウィドウアンカー
63166095 2 --閃刀起動-エンゲージ
03285551 2 --アラメシアの儀
48130397 2 --超融合
11110587 2 --隣の芝刈り
31434645 2 --呪われしエルドランド
24224830 2 --墓穴の指名者
08949584 2 --ヒーローアライブ
47679935 2 --暴走魔法陣
89208725 2 --メタバース
!2021.10
#forbidden
91869203 0 --アマゾネスの射手
......
diff --git a/source/Irrlicht/CGUIEditBox.cpp b/source/Irrlicht/CGUIEditBox.cpp
index 395fb69..323c9a2 100644
--- a/source/Irrlicht/CGUIEditBox.cpp
+++ b/source/Irrlicht/CGUIEditBox.cpp
@@ -287,9 +287,11 @@ bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
- core::stringc s;
- s = Text.subString(realmbgn, realmend - realmbgn).c_str();
- Operator->copyToClipboard(s.c_str());
+ const int max_char_size = sizeof(wchar_t) * 3 / 2;
+ int max_size = (realmend - realmbgn)*max_char_size + 1;
+ c8 *s = new char[max_size];
+ wcstombs(s, Text.subString(realmbgn, realmend-realmbgn).c_str(), max_size);
+ Operator->copyToClipboard(s);
}
break;
case KEY_KEY_X:
@@ -300,9 +302,11 @@ bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// copy
- core::stringc sc;
- sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
- Operator->copyToClipboard(sc.c_str());
+ const int max_char_size = sizeof(wchar_t) * 3 / 2;
+ int max_size = (realmend - realmbgn)*max_char_size + 1;
+ c8 *s = new char[max_size];
+ wcstombs(s, Text.subString(realmbgn, realmend-realmbgn).c_str(), max_size);
+ Operator->copyToClipboard(s);
if (isEnabled())
{
diff --git a/source/Irrlicht/MacOSX/AppDelegate.h b/source/Irrlicht/MacOSX/AppDelegate.h
index ccb116d..29705f2 100644
--- a/source/Irrlicht/MacOSX/AppDelegate.h
+++ b/source/Irrlicht/MacOSX/AppDelegate.h
@@ -10,7 +10,7 @@
#import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h"
-@interface AppDelegate : NSObject
+@interface AppDelegate : NSTextView <NSApplicationDelegate>
{
BOOL _quit;
irr::CIrrDeviceMacOSX *_device;
diff --git a/source/Irrlicht/MacOSX/AppDelegate.mm b/source/Irrlicht/MacOSX/AppDelegate.mm
index 14a7f86..0ab0c43 100644
--- a/source/Irrlicht/MacOSX/AppDelegate.mm
+++ b/source/Irrlicht/MacOSX/AppDelegate.mm
@@ -74,6 +74,30 @@
return (_quit);
}
+
+- (void)keyDown:(NSEvent *)event
+{
+ [self interpretKeyEvents:@[event]];
+}
+
+- (void)insertText:(id)string
+{
+ [self setString: @""];
+ if ([string isKindOfClass:[NSAttributedString class]])
+ {
+ _device->handleInputEvent([[string string] UTF8String]);
+ }
+ else
+ {
+ _device->handleInputEvent([string UTF8String]);
+ }
+}
+
+- (void)doCommandBySelector:(SEL)selector
+{
+ _device->processKeyEvent();
+}
+
@end
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
index f629588..d2fefae 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
@@ -95,6 +95,8 @@ namespace irr
void setMouseLocation(int x, int y);
void setResize(int width, int height);
void setCursorVisible(bool visible);
+ void handleInputEvent(const char *str);
+ void processKeyEvent();
private:
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
index ad493fc..8692d0c 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
@@ -496,7 +496,7 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
{
[[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
- [NSApp setDelegate:(id<NSFileManagerDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
+ [NSApp setDelegate:[[[[AppDelegate alloc] initWithDevice:this] initWithFrame:NSZeroRect] autorelease]];
[NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]];
[NSApp finishLaunching];
}
@@ -592,6 +592,38 @@ void CIrrDeviceMacOSX::closeDevice()
CGLContext = NULL;
}
+void CIrrDeviceMacOSX::processKeyEvent()
+{
+ irr::SEvent ievent;
+ NSEvent *event = [[NSApplication sharedApplication] currentEvent];
+ postKeyEvent(event, ievent, true);
+}
+
+void CIrrDeviceMacOSX::handleInputEvent(const char *cStr)
+{
+ SEvent ievent;
+
+ // TODO: we should have such a function in core::string
+ size_t lenOld = strlen(cStr);
+ wchar_t *ws = new wchar_t[lenOld + 1];
+ size_t len = mbstowcs(ws,cStr,lenOld);
+ ws[len] = 0;
+ irr::core::stringw widep(ws);
+ delete[] ws;
+
+ ievent.EventType = irr::EET_KEY_INPUT_EVENT;
+ ievent.KeyInput.Key = (irr::EKEY_CODE)0;
+ ievent.KeyInput.PressedDown = true;
+ ievent.KeyInput.Shift = false;
+ ievent.KeyInput.Control = false;
+
+ for (int i = 0; i < widep.size(); ++i)
+ {
+ ievent.KeyInput.Char = widep[i];
+ postEventFromUser(ievent);
+ }
+}
+
bool CIrrDeviceMacOSX::createWindow()
{
CGDisplayErr error;
@@ -881,6 +913,8 @@ bool CIrrDeviceMacOSX::createWindow()
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
}
+
+ [[Window contentView] addSubview:(AppDelegate*)[NSApp delegate]];
}
return (result);
@@ -971,6 +1005,33 @@ bool CIrrDeviceMacOSX::run()
os::Timer::tick();
storeMouseLocation();
+ auto focusElement = getGUIEnvironment()->getFocus();
+ bool editing = focusElement && focusElement->getType() == irr::gui::EGUIET_EDIT_BOX;
+
+ if (!editing)
+ {
+ [Window makeFirstResponder:nil];
+ }
+ else
+ {
+ auto textView = (NSTextView*)[NSApp delegate];
+ auto crect = focusElement->getAbsolutePosition();
+
+ // ensure font height enough to fill the rect, otherwize ime window will overlaps the edit box
+ [textView setFont:[NSFont userFontOfSize:crect.getHeight()]];
+
+ // change origin from top left to bottom right
+ NSRect rect = {
+ crect.UpperLeftCorner.X,
+ [[textView superview] frame].size.height - crect.LowerRightCorner.Y,
+ crect.getWidth(), crect.getHeight(),
+ };
+ [textView setFrame:rect];
+
+ // start to receive input events
+ [Window makeFirstResponder:textView];
+ }
+
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event != nil)
{
@@ -979,6 +1040,13 @@ bool CIrrDeviceMacOSX::run()
switch([(NSEvent *)event type])
{
case NSKeyDown:
+ if (editing)
+ {
+ // delegate to text edit control to handle text input
+ [NSApp sendEvent:event];
+ break;
+ }
+
postKeyEvent(event,ievent,true);
break;
@@ -1199,22 +1267,22 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
}
else
{
- cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
+ cStr = (unsigned char *)[str UTF8String];
if (cStr != NULL && strlen((char*)cStr) > 0)
{
mchar = cStr[0];
mkey = toupper(mchar);
- if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
- {
- if (mkey == 'C' || mkey == 'V' || mkey == 'X')
- {
- mchar = 0;
- skipCommand = true;
- }
- }
}
}
}
+ if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
+ {
+ if (mkey == 'C' || mkey == 'V' || mkey == 'X')
+ {
+ mchar = 0;
+ skipCommand = true;
+ }
+ }
ievent.EventType = irr::EET_KEY_INPUT_EVENT;
ievent.KeyInput.Key = (irr::EKEY_CODE)mkey;
diff --git a/source/Irrlicht/MacOSX/OSXClipboard.mm b/source/Irrlicht/MacOSX/OSXClipboard.mm
index d549911..1925e80 100644
--- a/source/Irrlicht/MacOSX/OSXClipboard.mm
+++ b/source/Irrlicht/MacOSX/OSXClipboard.mm
@@ -13,7 +13,7 @@ void OSXCopyToClipboard(const char *text)
if ((text != NULL) && (strlen(text) > 0))
{
- str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
+ str = [NSString stringWithUTF8String:text];
board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType];
@@ -30,7 +30,7 @@ char* OSXCopyFromClipboard()
board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType];
if (str != nil)
- result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
+ result = (char*)[str UTF8String];
return (result);
}
diff -ur --strip-trailing-cr irrlicht/include/IOSOperator.h irrlicht-fixed/include/IOSOperator.h
--- irrlicht/include/IOSOperator.h 2012-11-03 19:08:34.000000000 +0800
+++ irrlicht-fixed/include/IOSOperator.h 2017-09-09 18:50:04.693119800 +0800
@@ -26,11 +26,11 @@
}
//! Copies text to the clipboard
- virtual void copyToClipboard(const c8* text) const = 0;
+ virtual void copyToClipboard(const c16* text) const = 0;
//! Get text from the clipboard
/** \return Returns 0 if no string is in there. */
- virtual const c8* getTextFromClipboard() const = 0;
+ virtual const c16* getTextFromClipboard() const = 0;
//! Get the processor speed in megahertz
/** \param MHz The integer variable to store the speed in.
diff -ur --strip-trailing-cr irrlicht/include/IrrCompileConfig.h irrlicht-fixed/include/IrrCompileConfig.h
--- irrlicht/include/IrrCompileConfig.h 2016-07-09 13:02:32.000000000 +0800
+++ irrlicht-fixed/include/IrrCompileConfig.h 2017-09-09 18:50:04.695119900 +0800
@@ -233,7 +233,9 @@
disable this feature, the engine behave as before (ansi). This is currently only supported
for Windows based systems. You also have to set #define UNICODE for this to compile.
*/
-//#define _IRR_WCHAR_FILESYSTEM
+#if defined(_IRR_WINDOWS_) && (defined(_UNICODE) || defined(UNICODE))
+#define _IRR_WCHAR_FILESYSTEM
+#endif
#ifdef NO_IRR_WCHAR_FILESYSTEM
#undef _IRR_WCHAR_FILESYSTEM
#endif
diff -ur --strip-trailing-cr irrlicht/include/irrTypes.h irrlicht-fixed/include/irrTypes.h
--- irrlicht/include/irrTypes.h 2012-11-19 18:20:40.000000000 +0800
+++ irrlicht-fixed/include/irrTypes.h 2017-09-09 18:54:19.126672600 +0800
@@ -48,6 +48,9 @@
typedef signed short s16;
#endif
+//! 16 bit character variable.
+/** This is a typedef for wchar_t, it ensures portability of the engine. */
+typedef wchar_t c16;
//! 32 bit unsigned variable.
diff -ur --strip-trailing-cr irrlicht/src/CGUIEditBox.cpp irrlicht-fixed/src/CGUIEditBox.cpp
--- irrlicht/src/CGUIEditBox.cpp 2014-09-17 20:23:10.000000000 +0800
+++ irrlicht-fixed/src/CGUIEditBox.cpp 2017-09-09 18:50:04.709120800 +0800
@@ -287,7 +287,7 @@
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
- core::stringc s;
+ core::stringw s;
s = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(s.c_str());
}
@@ -300,7 +300,7 @@
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// copy
- core::stringc sc;
+ core::stringw sc;
sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
Operator->copyToClipboard(sc.c_str());
@@ -330,16 +330,10 @@
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// add new character
- const c8* p = Operator->getTextFromClipboard();
+ const c16* p = Operator->getTextFromClipboard();
if (p)
{
- // TODO: we should have such a function in core::string
- size_t lenOld = strlen(p);
- wchar_t *ws = new wchar_t[lenOld + 1];
- size_t len = mbstowcs(ws,p,lenOld);
- ws[len] = 0;
- irr::core::stringw widep(ws);
- delete[] ws;
+ irr::core::stringw widep(p);
if (MarkBegin == MarkEnd)
{
@@ -664,6 +658,16 @@
case KEY_ESCAPE:
case KEY_TAB:
case KEY_SHIFT:
+ case KEY_LSHIFT:
+ case KEY_RSHIFT:
+ case KEY_MENU:
+ case KEY_LMENU:
+ case KEY_RMENU:
+ case KEY_LWIN:
+ case KEY_RWIN:
+ case KEY_CAPITAL:
+ case KEY_NUMLOCK:
+ case KEY_SCROLL:
case KEY_F1:
case KEY_F2:
case KEY_F3:
diff -ur --strip-trailing-cr irrlicht/src/CGUIListBox.cpp irrlicht-fixed/src/CGUIListBox.cpp
--- irrlicht/src/CGUIListBox.cpp 2016-05-26 12:09:34.000000000 +0800
+++ irrlicht-fixed/src/CGUIListBox.cpp 2017-09-09 18:50:04.720121400 +0800
@@ -425,7 +425,7 @@
}
case EMIE_MOUSE_MOVED:
- if (Selecting || MoveOverSelect)
+ if (MoveOverSelect)
{
if (isPointInside(p))
{
diff -ur --strip-trailing-cr irrlicht/src/CIrrDeviceWin32.cpp irrlicht-fixed/src/CIrrDeviceWin32.cpp
--- irrlicht/src/CIrrDeviceWin32.cpp 2016-05-26 12:09:34.000000000 +0800
+++ irrlicht-fixed/src/CIrrDeviceWin32.cpp 2017-09-09 18:56:09.679995900 +0800
@@ -20,6 +20,8 @@
#include "COSOperator.h"
#include "dimension2d.h"
#include "IGUISpriteBank.h"
+#include "IGUIEnvironment.h"
+#include "IGUIElement.h"
#include <winuser.h>
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
@@ -749,6 +751,26 @@
return 0;
}
+ {
+ dev = getDeviceFromHWnd(hWnd);
+ if (dev)
+ {
+ irr::gui::IGUIElement* ele = dev->getGUIEnvironment()->getFocus();
+ if (!ele || (ele->getType() != irr::gui::EGUIET_EDIT_BOX) || !ele->isEnabled())
+ {
+ HIMC hIMC = ImmGetContext(hWnd);
+ if (hIMC)
+ {
+ ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
+ ImmReleaseContext(hWnd, hIMC);
+ }
+ ImmAssociateContextEx(hWnd, NULL, 0);
+ }
+ else
+ ImmAssociateContextEx(hWnd, NULL, IACE_DEFAULT);
+ }
+ }
+
switch (message)
{
case WM_PAINT:
@@ -773,7 +795,11 @@
event.KeyInput.Key = (irr::EKEY_CODE)wParam;
event.KeyInput.PressedDown = (message==WM_KEYDOWN || message == WM_SYSKEYDOWN);
+#ifdef MAPVK_VSC_TO_VK_EX
+ const UINT MY_MAPVK_VSC_TO_VK_EX = MAPVK_VSC_TO_VK_EX;
+#else
const UINT MY_MAPVK_VSC_TO_VK_EX = 3; // MAPVK_VSC_TO_VK_EX should be in SDK according to MSDN, but isn't in mine.
+#endif
if ( event.KeyInput.Key == irr::KEY_SHIFT )
{
// this will fail on systems before windows NT/2000/XP, not sure _what_ will return there instead.
@@ -904,6 +930,53 @@
KEYBOARD_INPUT_HKL = GetKeyboardLayout(0);
KEYBOARD_INPUT_CODEPAGE = LocaleIdToCodepage( LOWORD(KEYBOARD_INPUT_HKL) );
return 0;
+
+ case WM_IME_STARTCOMPOSITION:
+ {
+ dev = getDeviceFromHWnd(hWnd);
+ irr::gui::IGUIElement* ele = dev->getGUIEnvironment()->getFocus();
+ if (!ele)
+ break;
+ irr::core::position2di pos = ele->getAbsolutePosition().UpperLeftCorner;
+ COMPOSITIONFORM CompForm = { CFS_POINT, { pos.X, pos.Y + ele->getAbsolutePosition().getHeight() } };
+ HIMC hIMC = ImmGetContext(hWnd);
+ ImmSetCompositionWindow(hIMC, &CompForm);
+ ImmReleaseContext(hWnd, hIMC);
+ }
+ break;
+
+ case WM_IME_CHAR:
+ event.EventType = irr::EET_KEY_INPUT_EVENT;
+ event.KeyInput.PressedDown = true;
+#ifdef _UNICODE
+ event.KeyInput.Char = wParam;
+#else
+ BYTE ch[3];
+ if (wParam >> 8) {
+ ch[0] = wParam >> 8;
+ ch[1] = wParam & 0xff;
+ ch[2] = 0;
+ } else {
+ ch[0] = wParam;
+ ch[1] = 0;
+ }
+ WORD unicodeChar;
+ MultiByteToWideChar(
+ KEYBOARD_INPUT_CODEPAGE,
+ MB_PRECOMPOSED, // default
+ (LPCSTR)ch,
+ sizeof(wParam),
+ (WCHAR*)&unicodeChar,
+ 1);
+ event.KeyInput.Char = unicodeChar;
+#endif
+ event.KeyInput.Key = irr::KEY_ACCEPT;
+ event.KeyInput.Shift = 0;
+ event.KeyInput.Control = 0;
+ dev = getDeviceFromHWnd(hWnd);
+ if (dev)
+ dev->postEventFromUser(event);
+ return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
@@ -1797,8 +1870,8 @@
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
- // No message translation because we don't use WM_CHAR and it would conflict with our
- // deadkey handling.
+ // conflict with deadkey handling.
+ TranslateMessage(&msg);
if (ExternalWindow && msg.hwnd == HWnd)
WndProc(HWnd, msg.message, msg.wParam, msg.lParam);
diff -ur --strip-trailing-cr irrlicht/src/COSOperator.cpp irrlicht-fixed/src/COSOperator.cpp
--- irrlicht/src/COSOperator.cpp 2012-11-03 19:07:52.000000000 +0800
+++ irrlicht-fixed/src/COSOperator.cpp 2017-09-09 18:50:04.715121100 +0800
@@ -52,9 +52,9 @@
//! copies text to the clipboard
-void COSOperator::copyToClipboard(const c8* text) const
+void COSOperator::copyToClipboard(const c16* text) const
{
- if (strlen(text)==0)
+ if (wcslen(text)==0)
return;
// Windows version
@@ -66,15 +66,15 @@
EmptyClipboard();
HGLOBAL clipbuffer;
- char * buffer;
+ wchar_t * buffer;
- clipbuffer = GlobalAlloc(GMEM_DDESHARE, strlen(text)+1);
- buffer = (char*)GlobalLock(clipbuffer);
+ clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(wchar_t) * (wcslen(text) + 1));
+ buffer = (wchar_t*)GlobalLock(clipbuffer);
- strcpy(buffer, text);
+ wcscpy(buffer, text);
GlobalUnlock(clipbuffer);
- SetClipboardData(CF_TEXT, clipbuffer);
+ SetClipboardData(CF_UNICODETEXT, clipbuffer);
CloseClipboard();
// MacOSX version
@@ -93,7 +93,7 @@
//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
-const c8* COSOperator::getTextFromClipboard() const
+const c16* COSOperator::getTextFromClipboard() const
{
#if defined(_IRR_XBOX_PLATFORM_)
return 0;
@@ -101,10 +101,10 @@
if (!OpenClipboard(NULL))
return 0;
- char * buffer = 0;
+ wchar_t * buffer = 0;
- HANDLE hData = GetClipboardData( CF_TEXT );
- buffer = (char*)GlobalLock( hData );
+ HANDLE hData = GetClipboardData( CF_UNICODETEXT );
+ buffer = (wchar_t*)GlobalLock( hData );
GlobalUnlock( hData );
CloseClipboard();
return buffer;
diff -ur --strip-trailing-cr irrlicht/src/COSOperator.h irrlicht-fixed/src/COSOperator.h
--- irrlicht/src/COSOperator.h 2012-11-03 19:08:00.000000000 +0800
+++ irrlicht-fixed/src/COSOperator.h 2017-09-09 18:50:04.717121200 +0800
@@ -27,11 +27,11 @@
virtual const core::stringc& getOperatingSystemVersion() const;
//! copies text to the clipboard
- virtual void copyToClipboard(const c8* text) const;
+ virtual void copyToClipboard(const c16* text) const;
//! gets text from the clipboard
//! \return Returns 0 if no string is in there.
- virtual const c8* getTextFromClipboard() const;
+ virtual const c16* getTextFromClipboard() const;
//! gets the processor speed in megahertz
//! \param Mhz:
This diff is collapsed.
Subproject commit 3a75e12cda3ae09e6ff1272029c00b3bfb0db3e4
Subproject commit ef32ed0d101ae56101c1fb4d13f66b72cc485fe8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment