Commit 81f20984 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro into mac-test

parents 8705e6b4 06ea1af8
...@@ -230,7 +230,7 @@ CGUITTFont* CGUITTFont::create(IrrlichtDevice *device, const io::path& filename, ...@@ -230,7 +230,7 @@ CGUITTFont* CGUITTFont::create(IrrlichtDevice *device, const io::path& filename,
//! Constructor. //! Constructor.
CGUITTFont::CGUITTFont(IGUIEnvironment *env) CGUITTFont::CGUITTFont(IGUIEnvironment *env)
: use_monochrome(false), use_transparency(true), use_hinting(true), use_auto_hinting(true), : use_monochrome(false), use_transparency(true), use_hinting(true), use_auto_hinting(true),
batch_load_size(1), Device(0), Environment(env), Driver(0), GlobalKerningWidth(0), GlobalKerningHeight(0) { batch_load_size(1), Device(0), Environment(env), Driver(0), GlobalKerningWidth(0), GlobalKerningHeight(0), supposed_line_height(0) {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CGUITTFont"); setDebugName("CGUITTFont");
#endif #endif
...@@ -345,6 +345,24 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia ...@@ -345,6 +345,24 @@ bool CGUITTFont::load(const io::path& filename, const u32 size, const bool antia
getGlyphIndexByChar((uchar32_t)0); getGlyphIndexByChar((uchar32_t)0);
batch_load_size = old_size; batch_load_size = old_size;
// Calculate the supposed line height of this font (of this size) --
// Not using FT_SizeMetric::ascender or height, but actually by testing some of the glyphs,
// to see what should give a reasonable not cluttered line height.
// The ascender or height info may as well just be arbitrary ones.
// Get the maximum font height. Unfortunately, we have to do this hack as
// Irrlicht will draw things wrong. In FreeType, the font size is the
// maximum size for a single glyph, but that glyph may hang "under" the
// draw line, increasing the total font height to beyond the set size.
// Irrlicht does not understand this concept when drawing fonts. Also, I
// add +1 to give it a 1 pixel blank border. This makes things like
// tooltips look nicer.
s32 test1 = getHeightFromCharacter((uchar32_t)'g') + 1;
s32 test2 = getHeightFromCharacter((uchar32_t)'j') + 1;
s32 test3 = getHeightFromCharacter((uchar32_t)0x55B5) + 1;
supposed_line_height = core::max_(test1, core::max_(test2, test3));
return true; return true;
} }
...@@ -443,8 +461,8 @@ CGUITTGlyphPage* CGUITTFont::createGlyphPage(const u8& pixel_mode) { ...@@ -443,8 +461,8 @@ CGUITTGlyphPage* CGUITTFont::createGlyphPage(const u8& pixel_mode) {
if (page_texture_size.Width > max_texture_size.Width || page_texture_size.Height > max_texture_size.Height) if (page_texture_size.Width > max_texture_size.Width || page_texture_size.Height > max_texture_size.Height)
page_texture_size = max_texture_size; page_texture_size = max_texture_size;
page->texture_size = page_texture_size; page->texture_size = page_texture_size;
page->pixel_mode = pixel_mode; page->pixel_mode = pixel_mode;
if (page) { if (page) {
// Determine the number of glyph slots on the page and add it to the list of pages. // Determine the number of glyph slots on the page and add it to the list of pages.
...@@ -521,7 +539,7 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position ...@@ -521,7 +539,7 @@ void CGUITTFont::draw(const core::stringw& text, const core::rect<s32>& position
if (lineBreak) { if (lineBreak) {
previousChar = 0; previousChar = 0;
offset.Y += font_metrics.ascender / 64; offset.Y += supposed_line_height; //font_metrics.ascender / 64;
offset.X = position.UpperLeftCorner.X; offset.X = position.UpperLeftCorner.X;
if (hcenter) if (hcenter)
...@@ -576,20 +594,8 @@ core::dimension2d<u32> CGUITTFont::getDimension(const wchar_t* text) const { ...@@ -576,20 +594,8 @@ core::dimension2d<u32> CGUITTFont::getDimension(const wchar_t* text) const {
} }
core::dimension2d<u32> CGUITTFont::getDimension(const core::ustring& text) const { core::dimension2d<u32> CGUITTFont::getDimension(const core::ustring& text) const {
// Get the maximum font height. Unfortunately, we have to do this hack as core::dimension2d<u32> text_dimension(0, supposed_line_height);
// Irrlicht will draw things wrong. In FreeType, the font size is the core::dimension2d<u32> line(0, supposed_line_height);
// maximum size for a single glyph, but that glyph may hang "under" the
// draw line, increasing the total font height to beyond the set size.
// Irrlicht does not understand this concept when drawing fonts. Also, I
// add +1 to give it a 1 pixel blank border. This makes things like
// tooltips look nicer.
s32 test1 = getHeightFromCharacter((uchar32_t)'g') + 1;
s32 test2 = getHeightFromCharacter((uchar32_t)'j') + 1;
s32 test3 = getHeightFromCharacter((uchar32_t)'_') + 1;
s32 max_font_height = core::max_(test1, core::max_(test2, test3));
core::dimension2d<u32> text_dimension(0, max_font_height);
core::dimension2d<u32> line(0, max_font_height);
uchar32_t previousChar = 0; uchar32_t previousChar = 0;
core::ustring::const_iterator iter = text.begin(); core::ustring::const_iterator iter = text.begin();
...@@ -618,7 +624,7 @@ core::dimension2d<u32> CGUITTFont::getDimension(const core::ustring& text) const ...@@ -618,7 +624,7 @@ core::dimension2d<u32> CGUITTFont::getDimension(const core::ustring& text) const
if (text_dimension.Width < line.Width) if (text_dimension.Width < line.Width)
text_dimension.Width = line.Width; text_dimension.Width = line.Width;
line.Width = 0; line.Width = 0;
line.Height = max_font_height; line.Height = supposed_line_height;
continue; continue;
} }
line.Width += getWidthFromCharacter(p); line.Width += getWidthFromCharacter(p);
...@@ -937,7 +943,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text ...@@ -937,7 +943,7 @@ core::array<scene::ISceneNode*> CGUITTFont::addTextSceneNode(const wchar_t* text
if (line_break) { if (line_break) {
previous_char = 0; previous_char = 0;
offset.Y -= tt_face->size->metrics.ascender / 64; offset.Y -= supposed_line_height; //tt_face->size->metrics.ascender / 64;
offset.X = start_point.X; offset.X = start_point.X;
if (center) if (center)
offset.X += (text_size.Width - getDimensionUntilEndOfLine(text + 1).Width) >> 1; offset.X += (text_size.Width - getDimensionUntilEndOfLine(text + 1).Width) >> 1;
......
...@@ -143,12 +143,11 @@ public: ...@@ -143,12 +143,11 @@ public:
void updateTexture() { void updateTexture() {
if (!dirty) return; if (!dirty) return;
if (!texture) if (!texture) {
{
if (!createPageTexture(pixel_mode, texture_size)) if (!createPageTexture(pixel_mode, texture_size))
// TODO: add error message? // TODO: add error message?
return; return;
} }
void* ptr = texture->lock(); void* ptr = texture->lock();
video::ECOLOR_FORMAT format = texture->getColorFormat(); video::ECOLOR_FORMAT format = texture->getColorFormat();
...@@ -378,6 +377,7 @@ private: ...@@ -378,6 +377,7 @@ private:
s32 GlobalKerningWidth; s32 GlobalKerningWidth;
s32 GlobalKerningHeight; s32 GlobalKerningHeight;
s32 supposed_line_height;
core::ustring Invisible; core::ustring Invisible;
}; };
......
#ifndef __CONFIG_H #ifndef __CONFIG_H
#define __CONFIG_H #define __CONFIG_H
#pragma once #pragma once
#define _IRR_STATIC_LIB_ #define _IRR_STATIC_LIB_
#define IRR_COMPILE_WITH_DX9_DEV_PACK #define IRR_COMPILE_WITH_DX9_DEV_PACK
#ifdef _WIN32 #ifdef _WIN32
#include <WinSock2.h> #include <WinSock2.h>
#include <windows.h> #include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#define myswprintf _swprintf #define myswprintf _swprintf
#else #else
#define myswprintf swprintf #define myswprintf swprintf
#endif #endif
#define socklen_t int #define socklen_t int
#else //_WIN32 #else //_WIN32
#include <errno.h> #include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <unistd.h> #include <unistd.h>
#include <locale.h> #include <locale.h>
#define SD_BOTH 2 #define SD_BOTH 2
#define SOCKET int #define SOCKET int
#define closesocket close #define closesocket close
#define INVALID_SOCKET -1 #define INVALID_SOCKET -1
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#define SOCKADDR_IN sockaddr_in #define SOCKADDR_IN sockaddr_in
#define SOCKADDR sockaddr #define SOCKADDR sockaddr
#define SOCKET_ERRNO() (errno) #define SOCKET_ERRNO() (errno)
#include <wchar.h> #include <wchar.h>
#define myswprintf(buf, fmt, ...) swprintf(buf, 4096, fmt, ##__VA_ARGS__) #define myswprintf(buf, fmt, ...) swprintf(buf, 4096, fmt, ##__VA_ARGS__)
inline int _wtoi(const wchar_t * s) { inline int _wtoi(const wchar_t * s) {
wchar_t * endptr; wchar_t * endptr;
return (int)wcstol(s, &endptr, 10); return (int)wcstol(s, &endptr, 10);
} }
#endif #endif
#include <irrlicht.h> #include <irrlicht.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#include <OpenGL/glu.h> #include <OpenGL/glu.h>
#else #else
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#endif #endif
#include "CGUITTFont.h" #include "CGUITTFont.h"
#include "CGUIImageButton.h" #include "CGUIImageButton.h"
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
#include <time.h> #include <time.h>
#include "bufferio.h" #include "bufferio.h"
#include "mymutex.h" #include "mymutex.h"
#include "mysignal.h" #include "mysignal.h"
#include "mythread.h" #include "mythread.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/card.h" #include "../ocgcore/card.h"
using namespace irr; using namespace irr;
using namespace core; using namespace core;
using namespace scene; using namespace scene;
using namespace video; using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
extern const unsigned short PRO_VERSION; extern const unsigned short PRO_VERSION;
extern int enable_log; extern int enable_log;
extern bool exit_on_return; extern bool exit_on_return;
extern bool open_file; extern bool open_file;
extern wchar_t open_file_name[256]; extern wchar_t open_file_name[256];
#endif #endif
...@@ -224,11 +224,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -224,11 +224,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1410));
break; break;
} }
mainGame->imgCard->setImage(imageManager.tCover[0]);
// clear imgCard
mainGame->imgCard->setImage(imageManager.tCover[0]);
// send result to server
char deckbuf[1024]; char deckbuf[1024];
char* pdeck = deckbuf; char* pdeck = deckbuf;
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size());
......
...@@ -843,3 +843,5 @@ ...@@ -843,3 +843,5 @@
!setname 0x103 幻变骚灵 オルターガイスト !setname 0x103 幻变骚灵 オルターガイスト
!setname 0x104 机怪虫 クローラー !setname 0x104 机怪虫 クローラー
!setname 0x105 玄化 メタファイズ !setname 0x105 玄化 メタファイズ
!setname 0x106 复仇死灵 Vendread
!setname 0x107 F.A.
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