Improvements in textedit and hotkey manager
* Set textedit's cursor position to the end of text in some situations * Send hotkey messages to the current channel instead of default channel * Allow to overwrite sprites using otml and pngs
This commit is contained in:
parent
a8fbd6cdfc
commit
d5b4e0929f
|
@ -91,6 +91,7 @@ function EnterGame.init()
|
|||
if port == nil or port == 0 then port = 7171 end
|
||||
|
||||
enterGame:getChildById('accountNameTextEdit'):setText(account)
|
||||
enterGame:getChildById('accountNameTextEdit'):setCursorPos(-1)
|
||||
enterGame:getChildById('accountPasswordTextEdit'):setText(password)
|
||||
enterGame:getChildById('serverHostTextEdit'):setText(host)
|
||||
enterGame:getChildById('serverPortTextEdit'):setText(port)
|
||||
|
|
|
@ -223,6 +223,7 @@ end
|
|||
|
||||
function setTextEditText(text)
|
||||
consoleTextEdit:setText(text)
|
||||
consoleTextEdit:setCursorPos(-1)
|
||||
end
|
||||
|
||||
function openHelp()
|
||||
|
@ -529,7 +530,7 @@ function sendMessage(message, tab)
|
|||
if chatCommandInitial == chatCommandEnd then
|
||||
chatCommandPrivateRepeat = false
|
||||
if chatCommandInitial == "*" then
|
||||
consoleTextEdit:setText('*'.. chatCommandPrivate .. '* ')
|
||||
setTextEditText('*'.. chatCommandPrivate .. '* ')
|
||||
end
|
||||
message = chatCommandMessage:trim()
|
||||
chatCommandPrivateReady = true
|
||||
|
@ -615,7 +616,7 @@ function navigateMessageHistory(step)
|
|||
currentMessageIndex = math.min(math.max(currentMessageIndex + step, 0), numCommands)
|
||||
if currentMessageIndex > 0 then
|
||||
local command = messageHistory[numCommands - currentMessageIndex + 1]
|
||||
consoleTextEdit:setText(command)
|
||||
setTextEditText(command)
|
||||
else
|
||||
consoleTextEdit:clearText()
|
||||
end
|
||||
|
|
|
@ -289,7 +289,7 @@ function call(keyCombo)
|
|||
local hotKey = hotkeyList[keyCombo]
|
||||
if hotKey ~= nil and hotKey.itemId == nil and hotKey.value ~= '' then
|
||||
if hotKey.autoSend then
|
||||
g_game.talk(hotKey.value)
|
||||
modules.game_console.sendMessage(hotKey.value)
|
||||
else
|
||||
modules.game_console.setTextEditText(hotKey.value)
|
||||
end
|
||||
|
|
|
@ -146,8 +146,10 @@ void ThingType::unserializeOtml(const OTMLNodePtr& node)
|
|||
for(const OTMLNodePtr& node2 : node->children()) {
|
||||
if(node2->tag() == "opacity")
|
||||
m_opacity = node2->value<float>();
|
||||
if(node2->tag() == "notprewalkable")
|
||||
else if(node2->tag() == "notprewalkable")
|
||||
m_attribs.set(ThingAttrNotPreWalkable, node2->value<bool>());
|
||||
else if(node2->tag() == "image")
|
||||
m_customImage = node2->value();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,6 +188,10 @@ const TexturePtr& ThingType::getTexture(int animationPhase)
|
|||
{
|
||||
TexturePtr& animationPhaseTexture = m_textures[animationPhase];
|
||||
if(!animationPhaseTexture) {
|
||||
bool useCustomImage = false;
|
||||
if(animationPhase == 0 && !m_customImage.empty())
|
||||
useCustomImage = true;
|
||||
|
||||
// we don't need layers in common items, they will be pre-drawn
|
||||
int textureLayers = 1;
|
||||
int numLayers = m_layers;
|
||||
|
@ -197,7 +203,12 @@ const TexturePtr& ThingType::getTexture(int animationPhase)
|
|||
|
||||
int indexSize = textureLayers * m_numPatternX * m_numPatternY * m_numPatternZ;
|
||||
Size textureSize = getBestTextureDimension(m_size.width(), m_size.height(), indexSize);
|
||||
ImagePtr fullImage = ImagePtr(new Image(textureSize * Otc::TILE_PIXELS));
|
||||
ImagePtr fullImage;
|
||||
|
||||
if(useCustomImage)
|
||||
fullImage = Image::load(m_customImage);
|
||||
else
|
||||
fullImage = ImagePtr(new Image(textureSize * Otc::TILE_PIXELS));
|
||||
|
||||
m_texturesFramesRects[animationPhase].resize(indexSize);
|
||||
m_texturesFramesOriginRects[animationPhase].resize(indexSize);
|
||||
|
@ -212,6 +223,7 @@ const TexturePtr& ThingType::getTexture(int animationPhase)
|
|||
Point framePos = Point(frameIndex % (textureSize.width() / m_size.width()) * m_size.width(),
|
||||
frameIndex / (textureSize.width() / m_size.width()) * m_size.height()) * Otc::TILE_PIXELS;
|
||||
|
||||
if(!useCustomImage) {
|
||||
for(int h = 0; h < m_size.height(); ++h) {
|
||||
for(int w = 0; w < m_size.width(); ++w) {
|
||||
uint spriteIndex = getSpriteIndex(w, h, spriteMask ? 1 : l, x, y, z, animationPhase);
|
||||
|
@ -228,6 +240,7 @@ const TexturePtr& ThingType::getTexture(int animationPhase)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rect drawRect(framePos + Point(m_size.width(), m_size.height()) * Otc::TILE_PIXELS - Point(1,1), framePos);
|
||||
for(int x = framePos.x; x < framePos.x + m_size.width() * Otc::TILE_PIXELS; ++x) {
|
||||
|
|
|
@ -202,6 +202,7 @@ private:
|
|||
int m_layers;
|
||||
int m_elevation;
|
||||
float m_opacity;
|
||||
std::string m_customImage;
|
||||
|
||||
std::vector<int> m_spritesIndex;
|
||||
std::vector<TexturePtr> m_textures;
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
void poll();
|
||||
|
||||
void clearTexturesCache();
|
||||
void preload(const std::string& fileName) { getTexture(fileName); }
|
||||
TexturePtr getTexture(const std::string& fileName);
|
||||
const TexturePtr& getEmptyTexture() { return m_emptyTexture; }
|
||||
|
||||
|
|
|
@ -294,6 +294,7 @@ void Application::registerLuaFunctions()
|
|||
|
||||
// Textures
|
||||
g_lua.registerSingletonClass("g_textures");
|
||||
g_lua.bindSingletonFunction("g_textures", "preload", &TextureManager::preload, &g_textures);
|
||||
g_lua.bindSingletonFunction("g_textures", "clearTexturesCache", &TextureManager::clearTexturesCache, &g_textures);
|
||||
|
||||
// UI
|
||||
|
|
|
@ -327,6 +327,9 @@ void UITextEdit::update(bool focusCursor)
|
|||
|
||||
void UITextEdit::setCursorPos(int pos)
|
||||
{
|
||||
if(pos < 0)
|
||||
pos = m_text.length();
|
||||
|
||||
if(pos != m_cursorPos) {
|
||||
if(pos < 0)
|
||||
m_cursorPos = 0;
|
||||
|
|
Loading…
Reference in New Issue