* And minor adjustments
This commit is contained in:
Eduardo Bart 2013-01-25 17:26:51 -02:00
parent c982ca81a5
commit 32c5f4285b
13 changed files with 121 additions and 60 deletions

View File

@ -26,7 +26,7 @@ locale = {
["4c) False Report to Gamemaster"] = "4c) Relatório falso para Gamemaster", ["4c) False Report to Gamemaster"] = "4c) Relatório falso para Gamemaster",
["Accept"] = "Aceitar", ["Accept"] = "Aceitar",
["Account name"] = "Nome da conta", ["Account name"] = "Nome da conta",
["Account Status:"] = "Estado da Conta:", ["Account Status"] = "Estado da Conta",
["Action"] = "Ação", ["Action"] = "Ação",
["Add"] = "Adicionar", ["Add"] = "Adicionar",
["Add new VIP"] = "Adicionar nova VIP", ["Add new VIP"] = "Adicionar nova VIP",

View File

@ -15,10 +15,6 @@ Panel
id: enableMusicSound id: enableMusicSound
!text: tr('Enable music sound') !text: tr('Enable music sound')
OptionCheckBox
id: enableEffectsSound
!text: tr('Enable effects sound')
Label Label
id: musicSoundVolumeLabel id: musicSoundVolumeLabel
!text: tr('Music volume: %d', 100) !text: tr('Music volume: %d', 100)

View File

@ -25,7 +25,6 @@ local defaultOptions = {
enableLights = true, enableLights = true,
enableShaders = true, enableShaders = true,
ambientLight = 25, ambientLight = 25,
enableEffectsSound = 0
} }
local optionsWindow local optionsWindow

View File

@ -38,7 +38,7 @@ function UIMiniWindowContainer:fitAll(noRemoveChild)
end end
end end
local selfHeight = self:getHeight() - (self:getMarginTop() + self:getMarginBottom() + self:getPaddingTop() + self:getPaddingBottom()) local selfHeight = self:getHeight() - (self:getPaddingTop() + self:getPaddingBottom())
if sumHeight <= selfHeight then if sumHeight <= selfHeight then
return return
end end

View File

@ -33,7 +33,7 @@ ConsoleTabBarPanel < MoveableTabBarPanel
align-bottom: true align-bottom: true
border-width: 1 border-width: 1
border-color: #202327 border-color: #202327
background: #00000044 background: #00000066
inverted-scroll: true inverted-scroll: true
padding: 1 padding: 1
@ -45,8 +45,6 @@ ConsoleTabBarPanel < MoveableTabBarPanel
layout: layout:
type: verticalBox type: verticalBox
align-bottom: true align-bottom: true
border-width: 1
border-color: #202327
inverted-scroll: true inverted-scroll: true
padding: 1 padding: 1
@onScrollbarChange: | @onScrollbarChange: |

View File

@ -660,8 +660,7 @@ function setupViewMode(mode)
gameMapPanel:addAnchor(AnchorRight, 'gameRightPanel', AnchorLeft) gameMapPanel:addAnchor(AnchorRight, 'gameRightPanel', AnchorLeft)
gameMapPanel:addAnchor(AnchorBottom, 'gameBottomPanel', AnchorTop) gameMapPanel:addAnchor(AnchorBottom, 'gameBottomPanel', AnchorTop)
gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom) gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom)
gameLeftPanel:setOn(false) gameLeftPanel:setOn(modules.client_options.getOption('showLeftPanel'))
gameLeftPanel:setVisible(false)
gameLeftPanel:setImageColor('white') gameLeftPanel:setImageColor('white')
gameRightPanel:setImageColor('white') gameRightPanel:setImageColor('white')
gameLeftPanel:setMarginTop(0) gameLeftPanel:setMarginTop(0)
@ -689,12 +688,13 @@ function setupViewMode(mode)
gameRootPanel:fill('parent') gameRootPanel:fill('parent')
gameLeftPanel:setImageColor('alpha') gameLeftPanel:setImageColor('alpha')
gameRightPanel:setImageColor('alpha') gameRightPanel:setImageColor('alpha')
gameLeftPanel:setMarginTop(36) gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu():getHeight() - gameLeftPanel:getPaddingTop())
gameRightPanel:setMarginTop(36) gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu():getHeight() - gameRightPanel:getPaddingTop())
gameLeftPanel:setOn(true) gameLeftPanel:setOn(true)
gameLeftPanel:setVisible(true) gameLeftPanel:setVisible(true)
gameRightPanel:setOn(true) gameRightPanel:setOn(true)
gameBottomPanel:setImageColor('#00000099') gameMapPanel:setOn(true)
gameBottomPanel:setImageColor('#ffffff88')
modules.client_topmenu.getTopMenu():setImageColor('#ffffff66') modules.client_topmenu.getTopMenu():setImageColor('#ffffff66')
if not limitZoom then if not limitZoom then
g_game.changeMapAwareRange(24, 20) g_game.changeMapAwareRange(24, 20)

View File

@ -4,6 +4,9 @@ GameSidePanel < UIMiniWindowContainer
image-border: 4 image-border: 4
padding: 4 padding: 4
width: 198 width: 198
layout:
type: verticalBox
//spacing: 1
GameBottomPanel < Panel GameBottomPanel < Panel
image-source: /images/ui/panel_bottom image-source: /images/ui/panel_bottom
@ -14,6 +17,9 @@ GameMapPanel < UIGameMap
image-source: /images/ui/panel_map image-source: /images/ui/panel_map
image-border: 4 image-border: 4
$on:
padding: 0
UIWidget UIWidget
id: gameRootPanel id: gameRootPanel
anchors.fill: parent anchors.fill: parent
@ -36,7 +42,6 @@ UIWidget
GameSidePanel GameSidePanel
id: gameLeftPanel id: gameLeftPanel
layout: verticalBox
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@ -49,7 +54,6 @@ UIWidget
GameSidePanel GameSidePanel
id: gameRightPanel id: gameRightPanel
layout: verticalBox
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom

View File

@ -189,7 +189,7 @@ function addMapFlag(pos, icon, message, flagId, version)
flagWidget.icon = icon flagWidget.icon = icon
flagWidget.description = message flagWidget.description = message
if message and message:len() > 0 then if message and message:len() > 0 then
flagWidget:setTooltip(tr(message)) flagWidget:setTooltip(message)
end end
flagWidget.id = flagId flagWidget.id = flagId
flagWidget.version = version flagWidget.version = version

View File

@ -21,7 +21,8 @@ function init()
onBaseSkillChange = onBaseSkillChange onBaseSkillChange = onBaseSkillChange
}) })
connect(g_game, { connect(g_game, {
onGameStart = refresh onGameStart = refresh,
onGameEnd = offline
}) })
skillsButton = modules.client_topmenu.addRightGameToggleButton('skillsButton', tr('Skills') .. ' (Ctrl+S)', '/images/topbuttons/skills', toggle) skillsButton = modules.client_topmenu.addRightGameToggleButton('skillsButton', tr('Skills') .. ' (Ctrl+S)', '/images/topbuttons/skills', toggle)
@ -55,7 +56,7 @@ function terminate()
}) })
disconnect(g_game, { disconnect(g_game, {
onGameStart = refresh, onGameStart = refresh,
onGameEnd = refresh onGameEnd = offline
}) })
g_keyboard.unbindKeyDown('Ctrl+S') g_keyboard.unbindKeyDown('Ctrl+S')
@ -63,6 +64,14 @@ function terminate()
skillsWindow:destroy() skillsWindow:destroy()
end end
function expForLevel(level)
return math.floor((50*level*level*level)/3 - 100*level*level + (850*level)/3 - 200)
end
function expToAdvance(currentLevel, currentExp)
return expForLevel(currentLevel+1) - currentExp
end
function resetSkillColor(id) function resetSkillColor(id)
local skill = skillsWindow:recursiveGetChildById(id) local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value') local widget = skill:getChildById('value')
@ -180,6 +189,9 @@ function refresh()
local player = g_game.getLocalPlayer() local player = g_game.getLocalPlayer()
if not player then return end if not player then return end
if expSpeedEvent then expSpeedEvent:cancel() end
expSpeedEvent = cycleEvent(checkExpSpeed, 30*1000)
onExperienceChange(player, player:getExperience()) onExperienceChange(player, player:getExperience())
onLevelChange(player, player:getLevel(), player:getLevelPercent()) onLevelChange(player, player:getLevel(), player:getLevelPercent())
onHealthChange(player, player:getHealth(), player:getMaxHealth()) onHealthChange(player, player:getHealth(), player:getMaxHealth())
@ -204,6 +216,10 @@ function refresh()
skillsWindow:setContentMaximumHeight(contentsPanel:getChildrenRect().height) skillsWindow:setContentMaximumHeight(contentsPanel:getChildrenRect().height)
end end
function offline()
expSpeedEvent:cancel()
end
function toggle() function toggle()
if skillsButton:isOn() then if skillsButton:isOn() then
skillsWindow:close() skillsWindow:close()
@ -214,6 +230,22 @@ function toggle()
end end
end end
function checkExpSpeed()
local player = g_game.getLocalPlayer()
local currentExp = player:getExperience()
local currentTime = g_clock.seconds()
if player.lastExps ~= nil then
player.expSpeed = (currentExp - player.lastExps[1][1])/(currentTime - player.lastExps[1][2])
onLevelChange(player, player:getLevel(), player:getLevelPercent())
else
player.lastExps = {}
end
table.insert(player.lastExps, {currentExp, currentTime})
if #player.lastExps > 10 then
table.remove(player.lastExps, 1)
end
end
function onMiniWindowClose() function onMiniWindowClose()
skillsButton:setOn(false) skillsButton:setOn(false)
end end
@ -231,21 +263,36 @@ function onSkillButtonClick(button)
end end
function onExperienceChange(localPlayer, value) function onExperienceChange(localPlayer, value)
setSkillValue('experience', tr(value)) setSkillValue('experience', value)
end end
function onLevelChange(localPlayer, value, percent) function onLevelChange(localPlayer, value, percent)
setSkillValue('level', tr(value)) setSkillValue('level', value)
setSkillPercent('level', percent, tr('You have %s percent to go', 100 - percent)) local text = tr('You have %s percent to go', 100 - percent) .. '\n' ..
tr('%s of experience left', expToAdvance(localPlayer:getLevel(), localPlayer:getExperience()))
if localPlayer.expSpeed ~= nil then
local expPerHour = math.floor(localPlayer.expSpeed * 3600)
if expPerHour > 0 then
local nextLevelExp = expForLevel(localPlayer:getLevel()+1)
local hoursLeft = (nextLevelExp - localPlayer:getExperience()) / expPerHour
local minutesLeft = math.floor((hoursLeft - math.floor(hoursLeft))*60)
hoursLeft = math.floor(hoursLeft)
text = text .. '\n' .. tr('%d of experience per hour', expPerHour)
text = text .. '\n' .. tr('Next level in %d hours and %d minutes', hoursLeft, minutesLeft)
end
end
setSkillPercent('level', percent, text)
end end
function onHealthChange(localPlayer, health, maxHealth) function onHealthChange(localPlayer, health, maxHealth)
setSkillValue('health', tr(health)) setSkillValue('health', health)
checkAlert('health', health, maxHealth, 30) checkAlert('health', health, maxHealth, 30)
end end
function onManaChange(localPlayer, mana, maxMana) function onManaChange(localPlayer, mana, maxMana)
setSkillValue('mana', tr(mana)) setSkillValue('mana', mana)
checkAlert('mana', mana, maxMana, 30) checkAlert('mana', mana, maxMana, 30)
end end

View File

@ -37,6 +37,7 @@
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/core/application.h> #include <framework/core/application.h>
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
#include <boost/concept_check.hpp>
enum { enum {
@ -163,16 +164,8 @@ void MapView::draw(const Rect& rect)
if(m_shaderSwitchDone && m_shader && m_fadeInTime > 0) if(m_shaderSwitchDone && m_shader && m_fadeInTime > 0)
fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.0f); fadeOpacity = std::min(m_fadeTimer.timeElapsed() / m_fadeInTime, 1.0f);
Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize; Rect srcRect = calcFramebufferSource(rect.size());
if(isFollowingCreature()) Point drawOffset = srcRect.topLeft();
drawOffset += m_followingCreature->getWalkOffset() * scaleFactor;
Size srcSize = rect.size();
Size srcVisible = m_visibleDimension * m_tileSize;
srcSize.scale(srcVisible, Fw::KeepAspectRatio);
drawOffset.x += (srcVisible.width() - srcSize.width()) / 2;
drawOffset.y += (srcVisible.height() - srcSize.height()) / 2;
Rect srcRect = Rect(drawOffset, srcSize);
if(m_shader && g_painter->hasShaders() && g_graphics.shouldUseShaders() && m_viewMode == NEAR_VIEW) { if(m_shader && g_painter->hasShaders() && g_graphics.shouldUseShaders() && m_viewMode == NEAR_VIEW) {
Rect framebufferRect = Rect(0,0, m_drawDimension * m_tileSize); Rect framebufferRect = Rect(0,0, m_drawDimension * m_tileSize);
@ -544,6 +537,49 @@ void MapView::setCameraPosition(const Position& pos)
requestVisibleTilesCacheUpdate(); requestVisibleTilesCacheUpdate();
} }
Position MapView::getPosition(const Point& point, const Size& mapSize)
{
Position cameraPosition = getCameraPosition();
// if we have no camera, its impossible to get the tile
if(!cameraPosition.isValid())
return Position();
Rect srcRect = calcFramebufferSource(mapSize);
float sh = srcRect.width() / (float)mapSize.width();
float sv = srcRect.height() / (float)mapSize.height();
Point framebufferPos = Point(point.x * sh, point.y * sv);
Point centerOffset = (framebufferPos + srcRect.topLeft()) / m_tileSize;
Point tilePos2D = getVisibleCenterOffset() - m_drawDimension.toPoint() + centerOffset + Point(2,2);
if(tilePos2D.x + cameraPosition.x < 0 && tilePos2D.y + cameraPosition.y < 0)
return Position();
Position position = Position(tilePos2D.x, tilePos2D.y, 0) + cameraPosition;
if(!position.isValid())
return Position();
return position;
}
Rect MapView::calcFramebufferSource(const Size& destSize)
{
float scaleFactor = m_tileSize/(float)Otc::TILE_PIXELS;
Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize;
if(isFollowingCreature())
drawOffset += m_followingCreature->getWalkOffset() * scaleFactor;
Size srcSize = destSize;
Size srcVisible = m_visibleDimension * m_tileSize;
srcSize.scale(srcVisible, Fw::KeepAspectRatio);
drawOffset.x += (srcVisible.width() - srcSize.width()) / 2;
drawOffset.y += (srcVisible.height() - srcSize.height()) / 2;
return Rect(drawOffset, srcSize);
}
int MapView::calcFirstVisibleFloor() int MapView::calcFirstVisibleFloor()
{ {
int z = 7; int z = 7;

View File

@ -107,9 +107,12 @@ public:
void setShader(const PainterShaderProgramPtr& shader, float fadein, float fadeout); void setShader(const PainterShaderProgramPtr& shader, float fadein, float fadeout);
PainterShaderProgramPtr getShader() { return m_shader; } PainterShaderProgramPtr getShader() { return m_shader; }
Position getPosition(const Point& point, const Size& mapSize);
MapViewPtr asMapView() { return static_self_cast<MapView>(); } MapViewPtr asMapView() { return static_self_cast<MapView>(); }
private: private:
Rect calcFramebufferSource(const Size& destSize);
int calcFirstVisibleFloor(); int calcFirstVisibleFloor();
int calcLastVisibleFloor(); int calcLastVisibleFloor();
Point transformPositionTo2D(const Position& position, const Position& relativePosition) { Point transformPositionTo2D(const Position& position, const Position& relativePosition) {

View File

@ -128,29 +128,7 @@ Position UIMap::getPosition(const Point& mousePos)
return Position(); return Position();
Point relativeMousePos = mousePos - m_mapRect.topLeft(); Point relativeMousePos = mousePos - m_mapRect.topLeft();
Size visibleSize = getVisibleDimension() * m_mapView->getTileSize(); return m_mapView->getPosition(relativeMousePos, m_mapRect.size());
Position cameraPosition = getCameraPosition();
// if we have no camera, its impossible to get the tile
if(!cameraPosition.isValid())
return Position();
float scaleFactor = m_mapView->getTileSize() / (float)Otc::TILE_PIXELS;
float horizontalStretchFactor = visibleSize.width() / (float)m_mapRect.width();
float verticalStretchFactor = visibleSize.height() / (float)m_mapRect.height();
Point tilePos2D = Point(relativeMousePos.x * horizontalStretchFactor, relativeMousePos.y * verticalStretchFactor);
if(m_mapView->isFollowingCreature())
tilePos2D += getFollowingCreature()->getWalkOffset() * scaleFactor;
tilePos2D /= m_mapView->getTileSize();
Point visibleCenterOffset = m_mapView->getVisibleCenterOffset();
Position position = Position(1 + (int)tilePos2D.x - visibleCenterOffset.x, 1 + (int)tilePos2D.y - visibleCenterOffset.y, 0) + cameraPosition;
if(!position.isValid())
return Position();
return position;
} }
TilePtr UIMap::getTile(const Point& mousePos) TilePtr UIMap::getTile(const Point& mousePos)

View File

@ -589,7 +589,7 @@ void UITextEdit::updateText()
void UITextEdit::onHoverChange(bool hovered) void UITextEdit::onHoverChange(bool hovered)
{ {
if(m_changeCursorImage) { if(m_changeCursorImage) {
if(hovered) if(hovered && !g_mouse.isCursorChanged())
g_mouse.pushCursor("text"); g_mouse.pushCursor("text");
else else
g_mouse.popCursor("text"); g_mouse.popCursor("text");