This commit is contained in:
BeniS 2013-02-02 03:38:17 +13:00
parent 7f5dda5c8f
commit 6cd71ea02e
11 changed files with 123 additions and 39 deletions

View File

@ -104,7 +104,7 @@ TabBarVerticalButton < UIButton
anchors.top: parent.top anchors.top: parent.top
$!first: $!first:
anchors.top: prev.bottom anchors.top: prev.bottom
margin-top: 5 margin-top: 10
$hover !checked: $hover !checked:
color: white color: white
icon-color: #cccccc icon-color: #cccccc

View File

@ -21,6 +21,18 @@ Panel
id: showLeftPanel id: showLeftPanel
!text: tr('Show left panel') !text: tr('Show left panel')
OptionCheckBox
id: displayNames
!text: tr('Display creature names')
OptionCheckBox
id: displayHealth
!text: tr('Display creature health bars')
OptionCheckBox
id: displayText
!text: tr('Display text messages')
Button Button
id: changeLocale id: changeLocale
!text: tr('Change language') !text: tr('Change language')

View File

@ -22,6 +22,9 @@ local defaultOptions = {
musicSoundVolume = 100, musicSoundVolume = 100,
enableLights = true, enableLights = true,
ambientLight = 25, ambientLight = 25,
displayNames = true,
displayHealth = true,
displayText = true
} }
local optionsWindow local optionsWindow
@ -78,6 +81,32 @@ local function setupGraphicsEngines()
end end
function init() function init()
optionsWindow = g_ui.displayUI('options')
optionsWindow:hide()
optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options'), '/images/topbuttons/options', toggle)
addEvent(function() setup() end)
g_keyboard.bindKeyDown('Ctrl+Shift+F', function() toggleOption('fullscreen') end)
g_keyboard.bindKeyDown('Ctrl+N', toggleDisplays)
audioButton = modules.client_topmenu.addLeftButton('audioButton', tr('Audio'), '/images/topbuttons/audio', function() toggleOption('enableAudio') end)
end
function terminate()
g_keyboard.unbindKeyDown('Ctrl+Shift+F')
g_keyboard.unbindKeyDown('Ctrl+N')
optionsWindow:destroy()
optionsButton:destroy()
audioButton:destroy()
optionsTabBar = nil
generalPanel = nil
consolePanel = nil
graphicsPanel = nil
audioPanel = nil
end
function setup()
-- load options -- load options
for k,v in pairs(defaultOptions) do for k,v in pairs(defaultOptions) do
g_settings.setDefault(k, v) g_settings.setDefault(k, v)
@ -88,12 +117,6 @@ function init()
end end
end end
g_keyboard.bindKeyDown('Ctrl+Shift+F', function() toggleOption('fullscreen') end)
optionsWindow = g_ui.displayUI('options')
optionsWindow:hide()
optionsButton = modules.client_topmenu.addLeftButton('optionsButton', tr('Options'), '/images/topbuttons/options', toggle)
optionsTabBar = optionsWindow:getChildById('optionsTabBar') optionsTabBar = optionsWindow:getChildById('optionsTabBar')
optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent')) optionsTabBar:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
@ -109,24 +132,9 @@ function init()
audioPanel = g_ui.loadUI('audio') audioPanel = g_ui.loadUI('audio')
optionsTabBar:addTab(tr('Audio'), audioPanel, '/images/optionstab/audio') optionsTabBar:addTab(tr('Audio'), audioPanel, '/images/optionstab/audio')
audioButton = modules.client_topmenu.addLeftButton('audioButton', tr('Audio'), '/images/topbuttons/audio', function() toggleOption('enableAudio') end)
setupGraphicsEngines() setupGraphicsEngines()
end end
function terminate()
--g_keyboard.unbindKeyDown('Ctrl+D')
g_keyboard.unbindKeyDown('Ctrl+Shift+F')
optionsWindow:destroy()
optionsButton:destroy()
audioButton:destroy()
optionsTabBar = nil
generalPanel = nil
consolePanel = nil
graphicsPanel = nil
audioPanel = nil
end
function toggle() function toggle()
if optionsWindow:isVisible() then if optionsWindow:isVisible() then
hide() hide()
@ -145,12 +153,29 @@ function hide()
optionsWindow:hide() optionsWindow:hide()
end end
function toggleDisplays()
if options['displayNames'] and options['displayHealth'] then
setOption('displayNames', false)
elseif options['displayHealth'] then
setOption('displayHealth', false)
else
if not options['displayNames'] and not options['displayHealth'] then
setOption('displayNames', true)
else
setOption('displayHealth', true)
end
end
end
function toggleOption(key) function toggleOption(key)
setOption(key, not getOption(key)) setOption(key, not getOption(key))
end end
function setOption(key, value) function setOption(key, value)
if options[key] == value then return end if options[key] == value then return end
local gameMapPanel = modules.game_interface.getMapPanel()
local panel = nil
if key == 'vsync' then if key == 'vsync' then
g_window.setVerticalSync(value) g_window.setVerticalSync(value)
elseif key == 'showFps' then elseif key == 'showFps' then
@ -165,6 +190,7 @@ function setOption(key, value)
end) end)
elseif key == 'fullscreen' then elseif key == 'fullscreen' then
g_window.setFullscreen(value) g_window.setFullscreen(value)
panel = graphicsPanel
elseif key == 'enableAudio' then elseif key == 'enableAudio' then
g_sounds.setAudioEnabled(value) g_sounds.setAudioEnabled(value)
addEvent(function() addEvent(function()
@ -228,7 +254,25 @@ function setOption(key, value)
end) end)
elseif key == 'painterEngine' then elseif key == 'painterEngine' then
g_graphics.selectPainterEngine(value) g_graphics.selectPainterEngine(value)
elseif key == 'displayNames' then
gameMapPanel:setDrawNames(value)
panel = generalPanel
elseif key == 'displayHealth' then
gameMapPanel:setDrawHealthBars(value)
panel = generalPanel
elseif key == 'displayText' then
gameMapPanel:setDrawTexts(value)
panel = generalPanel
end end
-- change value for keybind updates
if panel then
local widget = panel:recursiveGetChildById(key)
if widget and widget:getStyle().__class == 'UICheckBox' then
widget:setChecked(value)
end
end
g_settings.set(key, value) g_settings.set(key, value)
options[key] = value options[key] = value
end end

View File

@ -106,7 +106,6 @@ function bindKeys()
g_keyboard.bindKeyDown('Ctrl+Q', logout, gameRootPanel) g_keyboard.bindKeyDown('Ctrl+Q', logout, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+L', logout, gameRootPanel) g_keyboard.bindKeyDown('Ctrl+L', logout, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel) g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+N', function() gameMapPanel:setDrawTexts(not gameMapPanel:isDrawingTexts()) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel) g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
end end

View File

@ -57,10 +57,14 @@ namespace Otc
DrawStaticTexts = 512, DrawStaticTexts = 512,
DrawAnimatedTexts = 1024, DrawAnimatedTexts = 1024,
DrawAnimations = 2048, DrawAnimations = 2048,
DrawBars = 4096,
DrawNames = 8192,
DrawLights = 16384,
DrawWalls = DrawOnBottom | DrawOnTop, DrawWalls = DrawOnBottom | DrawOnTop,
DrawEverything = DrawGround | DrawGroundBorders | DrawWalls | DrawItems | DrawEverything = DrawGround | DrawGroundBorders | DrawWalls | DrawItems |
DrawCreatures | DrawEffects | DrawMissiles | DrawCreaturesInformation | DrawCreatures | DrawEffects | DrawMissiles | DrawCreaturesInformation |
DrawStaticTexts | DrawAnimatedTexts | DrawAnimations DrawStaticTexts | DrawAnimatedTexts | DrawAnimations | DrawBars | DrawNames |
DrawLights
}; };
enum DatOpts { enum DatOpts {

View File

@ -226,7 +226,7 @@ void Creature::drawOutfit(const Rect& destRect, bool resize)
} }
} }
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect) void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
{ {
if(m_healthPercent < 1) // creature is dead if(m_healthPercent < 1) // creature is dead
return; return;
@ -255,17 +255,22 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
healthRect.setWidth((m_healthPercent / 100.0) * 25); healthRect.setWidth((m_healthPercent / 100.0) * 25);
// draw // draw
if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
fillColor = Color(0x66, 0xcc, 0xff);
if(drawFlags & Otc::DrawBars) {
g_painter->setColor(Color::black); g_painter->setColor(Color::black);
g_painter->drawFilledRect(backgroundRect); g_painter->drawFilledRect(backgroundRect);
if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
g_painter->setColor(Color(0x66, 0xcc, 0xff));
else
g_painter->setColor(fillColor); g_painter->setColor(fillColor);
g_painter->drawFilledRect(healthRect); g_painter->drawFilledRect(healthRect);
}
if(drawFlags & Otc::DrawNames) {
if(g_painter->getColor() != fillColor)
g_painter->setColor(fillColor);
m_nameCache.draw(textRect); m_nameCache.draw(textRect);
}
if(m_skull != Otc::SkullNone && m_skullTexture) { if(m_skull != Otc::SkullNone && m_skullTexture) {
g_painter->setColor(Color::white); g_painter->setColor(Color::white);

View File

@ -48,7 +48,7 @@ public:
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView = nullptr); void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView = nullptr);
void drawOutfit(const Rect& destRect, bool resize); void drawOutfit(const Rect& destRect, bool resize);
void drawInformation(const Point& point, bool useGray, const Rect& parentRect); void drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags);
void setId(uint32 id) { m_id = id; } void setId(uint32 id) { m_id = id; }
void setName(const std::string& name); void setName(const std::string& name);

View File

@ -557,6 +557,8 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIMap>("setAutoViewMode", &UIMap::setAutoViewMode); g_lua.bindClassMemberFunction<UIMap>("setAutoViewMode", &UIMap::setAutoViewMode);
g_lua.bindClassMemberFunction<UIMap>("setDrawFlags", &UIMap::setDrawFlags); g_lua.bindClassMemberFunction<UIMap>("setDrawFlags", &UIMap::setDrawFlags);
g_lua.bindClassMemberFunction<UIMap>("setDrawTexts", &UIMap::setDrawTexts); g_lua.bindClassMemberFunction<UIMap>("setDrawTexts", &UIMap::setDrawTexts);
g_lua.bindClassMemberFunction<UIMap>("setDrawNames", &UIMap::setDrawNames);
g_lua.bindClassMemberFunction<UIMap>("setDrawHealthBars", &UIMap::setDrawHealthBars);
g_lua.bindClassMemberFunction<UIMap>("setDrawLights", &UIMap::setDrawLights); g_lua.bindClassMemberFunction<UIMap>("setDrawLights", &UIMap::setDrawLights);
g_lua.bindClassMemberFunction<UIMap>("setAnimated", &UIMap::setAnimated); g_lua.bindClassMemberFunction<UIMap>("setAnimated", &UIMap::setAnimated);
g_lua.bindClassMemberFunction<UIMap>("setKeepAspectRatio", &UIMap::setKeepAspectRatio); g_lua.bindClassMemberFunction<UIMap>("setKeepAspectRatio", &UIMap::setKeepAspectRatio);
@ -566,6 +568,8 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIMap>("isMultifloor", &UIMap::isMultifloor); g_lua.bindClassMemberFunction<UIMap>("isMultifloor", &UIMap::isMultifloor);
g_lua.bindClassMemberFunction<UIMap>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled); g_lua.bindClassMemberFunction<UIMap>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts); g_lua.bindClassMemberFunction<UIMap>("isDrawingTexts", &UIMap::isDrawingTexts);
g_lua.bindClassMemberFunction<UIMap>("isDrawingNames", &UIMap::isDrawingNames);
g_lua.bindClassMemberFunction<UIMap>("isDrawingHealthBars", &UIMap::isDrawingHealthBars);
g_lua.bindClassMemberFunction<UIMap>("isDrawingLights", &UIMap::isDrawingLights); g_lua.bindClassMemberFunction<UIMap>("isDrawingLights", &UIMap::isDrawingLights);
g_lua.bindClassMemberFunction<UIMap>("isLimitVisibleRangeEnabled", &UIMap::isLimitVisibleRangeEnabled); g_lua.bindClassMemberFunction<UIMap>("isLimitVisibleRangeEnabled", &UIMap::isLimitVisibleRangeEnabled);
g_lua.bindClassMemberFunction<UIMap>("isAnimating", &UIMap::isAnimating); g_lua.bindClassMemberFunction<UIMap>("isAnimating", &UIMap::isAnimating);

View File

@ -204,7 +204,7 @@ void MapView::draw(const Rect& rect)
float verticalStretchFactor = rect.height() / (float)srcRect.height(); float verticalStretchFactor = rect.height() / (float)srcRect.height();
// avoid drawing texts on map in far zoom outs // avoid drawing texts on map in far zoom outs
if(m_viewMode == NEAR_VIEW && m_drawTexts) { if(m_viewMode == NEAR_VIEW) {
for(const CreaturePtr& creature : m_cachedFloorVisibleCreatures) { for(const CreaturePtr& creature : m_cachedFloorVisibleCreatures) {
if(!creature->canBeSeen()) if(!creature->canBeSeen())
continue; continue;
@ -218,7 +218,10 @@ void MapView::draw(const Rect& rect)
p.y = p.y * verticalStretchFactor; p.y = p.y * verticalStretchFactor;
p += rect.topLeft(); p += rect.topLeft();
creature->drawInformation(p, g_map.isCovered(pos, m_cachedFirstVisibleFloor), rect); int flags = 0;
if(m_drawNames){ flags = Otc::DrawNames; }
if(m_drawHealthBars) { flags |= Otc::DrawBars; }
creature->drawInformation(p, g_map.isCovered(pos, m_cachedFirstVisibleFloor), rect, flags);
} }
} }

View File

@ -98,12 +98,18 @@ public:
void setDrawTexts(bool enable) { m_drawTexts = enable; } void setDrawTexts(bool enable) { m_drawTexts = enable; }
bool isDrawingTexts() { return m_drawTexts; } bool isDrawingTexts() { return m_drawTexts; }
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); } void setDrawNames(bool enable) { m_drawNames = enable; }
bool isAnimating() { return m_animated; } bool isDrawingNames() { return m_drawNames; }
void setDrawHealthBars(bool enable) { m_drawHealthBars = enable; }
bool isDrawingHealthBars() { return m_drawHealthBars; }
void setDrawLights(bool enable); void setDrawLights(bool enable);
bool isDrawingLights() { return m_drawLights; } bool isDrawingLights() { return m_drawLights; }
void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); }
bool isAnimating() { return m_animated; }
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; }
@ -138,8 +144,11 @@ private:
stdext::boolean<true> m_animated; stdext::boolean<true> m_animated;
stdext::boolean<true> m_autoViewMode; stdext::boolean<true> m_autoViewMode;
stdext::boolean<true> m_drawTexts; stdext::boolean<true> m_drawTexts;
stdext::boolean<true> m_smooth; stdext::boolean<true> m_drawNames;
stdext::boolean<true> m_drawHealthBars;
stdext::boolean<false> m_drawLights; stdext::boolean<false> m_drawLights;
stdext::boolean<true> m_smooth;
stdext::boolean<true> m_follow; stdext::boolean<true> m_follow;
std::vector<TilePtr> m_cachedVisibleTiles; std::vector<TilePtr> m_cachedVisibleTiles;
std::vector<CreaturePtr> m_cachedFloorVisibleCreatures; std::vector<CreaturePtr> m_cachedFloorVisibleCreatures;

View File

@ -51,6 +51,8 @@ public:
void setAutoViewMode(bool enable) { m_mapView->setAutoViewMode(enable); } void setAutoViewMode(bool enable) { m_mapView->setAutoViewMode(enable); }
void setDrawFlags(Otc::DrawFlags drawFlags) { m_mapView->setDrawFlags(drawFlags); } void setDrawFlags(Otc::DrawFlags drawFlags) { m_mapView->setDrawFlags(drawFlags); }
void setDrawTexts(bool enable) { m_mapView->setDrawTexts(enable); } void setDrawTexts(bool enable) { m_mapView->setDrawTexts(enable); }
void setDrawNames(bool enable) { m_mapView->setDrawNames(enable); }
void setDrawHealthBars(bool enable) { m_mapView->setDrawHealthBars(enable); }
void setDrawLights(bool enable) { m_mapView->setDrawLights(enable); } void setDrawLights(bool enable) { m_mapView->setDrawLights(enable); }
void setAnimated(bool enable) { m_mapView->setAnimated(enable); } void setAnimated(bool enable) { m_mapView->setAnimated(enable); }
void setKeepAspectRatio(bool enable); void setKeepAspectRatio(bool enable);
@ -61,6 +63,8 @@ public:
bool isMultifloor() { return m_mapView->isMultifloor(); } bool isMultifloor() { return m_mapView->isMultifloor(); }
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); } bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
bool isDrawingTexts() { return m_mapView->isDrawingTexts(); } bool isDrawingTexts() { return m_mapView->isDrawingTexts(); }
bool isDrawingNames() { return m_mapView->isDrawingNames(); }
bool isDrawingHealthBars() { return m_mapView->isDrawingHealthBars(); }
bool isDrawingLights() { return m_mapView->isDrawingLights(); } bool isDrawingLights() { return m_mapView->isDrawingLights(); }
bool isAnimating() { return m_mapView->isAnimating(); } bool isAnimating() { return m_mapView->isAnimating(); }
bool isKeepAspectRatioEnabled() { return m_keepAspectRatio; } bool isKeepAspectRatioEnabled() { return m_keepAspectRatio; }