minor fixes
* change chase mode while walking and attacking * avoid lua errors in frame counter when starting
This commit is contained in:
parent
48d243a11d
commit
486837a61d
|
@ -81,5 +81,8 @@ TopPanel
|
||||||
margin-right: 5
|
margin-right: 5
|
||||||
@onSetup: |
|
@onSetup: |
|
||||||
cycleEvent(function()
|
cycleEvent(function()
|
||||||
rootWidget:recursiveGetChildById('frameCounter'):setText('FPS: ' .. g_app.getBackgroundPaneFps())
|
local frameCounter = rootWidget:recursiveGetChildById('frameCounter')
|
||||||
|
if frameCounter then
|
||||||
|
frameCounter:setText('FPS: ' .. g_app.getBackgroundPaneFps())
|
||||||
|
end
|
||||||
end, 250)
|
end, 250)
|
||||||
|
|
|
@ -11,7 +11,7 @@ local safeFightButton
|
||||||
local fightModeRadioGroup
|
local fightModeRadioGroup
|
||||||
|
|
||||||
-- private functions
|
-- private functions
|
||||||
local function onFightModeChange(self, selectedFightButton)
|
local function onSetFightMode(self, selectedFightButton)
|
||||||
if selectedFightButton == nil then return end
|
if selectedFightButton == nil then return end
|
||||||
local buttonId = selectedFightButton:getId()
|
local buttonId = selectedFightButton:getId()
|
||||||
local fightMode
|
local fightMode
|
||||||
|
@ -22,28 +22,21 @@ local function onFightModeChange(self, selectedFightButton)
|
||||||
else
|
else
|
||||||
fightMode = FightDefensive
|
fightMode = FightDefensive
|
||||||
end
|
end
|
||||||
if g_game.getFightMode() ~= fightMode then
|
g_game.setFightMode(fightMode)
|
||||||
g_game.setFightMode(fightMode)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onChaseModeChange(self, checked)
|
local function onSetChaseMode(self, checked)
|
||||||
local chaseMode
|
local chaseMode
|
||||||
if checked then
|
if checked then
|
||||||
chaseMode = ChaseOpponent
|
chaseMode = ChaseOpponent
|
||||||
else
|
else
|
||||||
chaseMode = DontChase
|
chaseMode = DontChase
|
||||||
end
|
end
|
||||||
if g_game.getChaseMode() ~= chaseMode then
|
g_game.setChaseMode(chaseMode)
|
||||||
g_game.setChaseMode(chaseMode)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onSafeFightChange(self, checked)
|
local function onSetSafeFight(self, checked)
|
||||||
local safeFight = not checked
|
g_game.setSafeFight(not checked)
|
||||||
if g_game.isSafeFight() ~= safeFight then
|
|
||||||
g_game.setSafeFight(not checked)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- public functions
|
-- public functions
|
||||||
|
@ -63,11 +56,16 @@ function CombatControls.init()
|
||||||
fightModeRadioGroup:addWidget(fightBalancedBox)
|
fightModeRadioGroup:addWidget(fightBalancedBox)
|
||||||
fightModeRadioGroup:addWidget(fightDefensiveBox)
|
fightModeRadioGroup:addWidget(fightDefensiveBox)
|
||||||
|
|
||||||
connect(fightModeRadioGroup, { onSelectionChange = onFightModeChange })
|
connect(fightModeRadioGroup, { onSelectionChange = onSetFightMode })
|
||||||
connect(chaseModeButton, { onCheckChange = onChaseModeChange })
|
connect(chaseModeButton, { onCheckChange = onSetChaseMode })
|
||||||
connect(safeFightButton, { onCheckChange = onSafeFightChange })
|
connect(safeFightButton, { onCheckChange = onSetSafeFight })
|
||||||
connect(g_game, { onGameStart = CombatControls.online })
|
connect(g_game, {
|
||||||
connect(g_game, { onGameEnd = CombatControls.offline })
|
onGameStart = CombatControls.online,
|
||||||
|
onGameEnd = CombatControls.offline,
|
||||||
|
onFightModeChange = CombatControls.update,
|
||||||
|
onChaseModeChange = CombatControls.update,
|
||||||
|
onSafeFightChange = CombatControls.update
|
||||||
|
})
|
||||||
|
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
CombatControls.online()
|
CombatControls.online()
|
||||||
|
@ -94,15 +92,18 @@ function CombatControls.terminate()
|
||||||
combatControlsWindow:destroy()
|
combatControlsWindow:destroy()
|
||||||
combatControlsWindow = nil
|
combatControlsWindow = nil
|
||||||
|
|
||||||
disconnect(g_game, { onGameStart = CombatControls.online })
|
disconnect(g_game, {
|
||||||
disconnect(g_game, { onGameEnd = CombatControls.offline })
|
onGameStart = CombatControls.online,
|
||||||
|
onGameEnd = CombatControls.offline,
|
||||||
|
onFightModeChange = CombatControls.update,
|
||||||
|
onChaseModeChange = CombatControls.update,
|
||||||
|
onSafeFightChange = CombatControls.update
|
||||||
|
})
|
||||||
|
|
||||||
CombatControls = nil
|
CombatControls = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function CombatControls.online()
|
function CombatControls.update()
|
||||||
combatControlsWindow:setVisible(combatControlsButton:isOn())
|
|
||||||
|
|
||||||
local fightMode = g_game.getFightMode()
|
local fightMode = g_game.getFightMode()
|
||||||
if fightMode == FightOffensive then
|
if fightMode == FightOffensive then
|
||||||
fightModeRadioGroup:selectWidget(fightOffensiveBox)
|
fightModeRadioGroup:selectWidget(fightOffensiveBox)
|
||||||
|
@ -119,6 +120,11 @@ function CombatControls.online()
|
||||||
safeFightButton:setChecked(not safeFight)
|
safeFightButton:setChecked(not safeFight)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CombatControls.online()
|
||||||
|
combatControlsWindow:setVisible(combatControlsButton:isOn())
|
||||||
|
CombatControls.update()
|
||||||
|
end
|
||||||
|
|
||||||
function CombatControls.offline()
|
function CombatControls.offline()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -487,6 +487,9 @@ void Game::forceWalk(Otc::Direction direction)
|
||||||
if(!canPerformGameAction())
|
if(!canPerformGameAction())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// always cancel chasing attacks
|
||||||
|
setChaseMode(Otc::DontChase);
|
||||||
|
|
||||||
switch(direction) {
|
switch(direction) {
|
||||||
case Otc::North:
|
case Otc::North:
|
||||||
m_protocolGame->sendWalkNorth();
|
m_protocolGame->sendWalkNorth();
|
||||||
|
@ -879,24 +882,33 @@ void Game::setChaseMode(Otc::ChaseModes chaseMode)
|
||||||
{
|
{
|
||||||
if(!canPerformGameAction())
|
if(!canPerformGameAction())
|
||||||
return;
|
return;
|
||||||
|
if(m_chaseMode == chaseMode)
|
||||||
|
return;
|
||||||
m_chaseMode = chaseMode;
|
m_chaseMode = chaseMode;
|
||||||
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
||||||
|
g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setFightMode(Otc::FightModes fightMode)
|
void Game::setFightMode(Otc::FightModes fightMode)
|
||||||
{
|
{
|
||||||
if(!canPerformGameAction())
|
if(!canPerformGameAction())
|
||||||
return;
|
return;
|
||||||
|
if(m_fightMode == fightMode)
|
||||||
|
return;
|
||||||
m_fightMode = fightMode;
|
m_fightMode = fightMode;
|
||||||
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
||||||
|
g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::setSafeFight(bool on)
|
void Game::setSafeFight(bool on)
|
||||||
{
|
{
|
||||||
if(!canPerformGameAction())
|
if(!canPerformGameAction())
|
||||||
return;
|
return;
|
||||||
|
if(m_safeFight == on)
|
||||||
|
return;
|
||||||
m_safeFight = on;
|
m_safeFight = on;
|
||||||
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight);
|
||||||
|
g_lua.callGlobalField("g_game", "onSafeFightChange", on);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::inspectNpcTrade(const ItemPtr& item)
|
void Game::inspectNpcTrade(const ItemPtr& item)
|
||||||
|
|
Loading…
Reference in New Issue