master
BeniS 11 years ago
parent 7f5dda5c8f
commit 6cd71ea02e

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

@ -21,6 +21,18 @@ Panel
id: showLeftPanel
!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
id: changeLocale
!text: tr('Change language')

@ -22,6 +22,9 @@ local defaultOptions = {
musicSoundVolume = 100,
enableLights = true,
ambientLight = 25,
displayNames = true,
displayHealth = true,
displayText = true
}
local optionsWindow
@ -78,6 +81,32 @@ local function setupGraphicsEngines()
end
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
for k,v in pairs(defaultOptions) do
g_settings.setDefault(k, v)
@ -88,12 +117,6 @@ function init()
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:setContentWidget(optionsWindow:getChildById('optionsTabContent'))
@ -109,24 +132,9 @@ function init()
audioPanel = g_ui.loadUI('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()
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()
if optionsWindow:isVisible() then
hide()
@ -145,12 +153,29 @@ function hide()
optionsWindow:hide()
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)
setOption(key, not getOption(key))
end
function setOption(key, value)
if options[key] == value then return end
local gameMapPanel = modules.game_interface.getMapPanel()
local panel = nil
if key == 'vsync' then
g_window.setVerticalSync(value)
elseif key == 'showFps' then
@ -165,6 +190,7 @@ function setOption(key, value)
end)
elseif key == 'fullscreen' then
g_window.setFullscreen(value)
panel = graphicsPanel
elseif key == 'enableAudio' then
g_sounds.setAudioEnabled(value)
addEvent(function()
@ -228,7 +254,25 @@ function setOption(key, value)
end)
elseif key == 'painterEngine' then
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
-- 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)
options[key] = value
end

@ -106,7 +106,6 @@ function bindKeys()
g_keyboard.bindKeyDown('Ctrl+Q', 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+N', function() gameMapPanel:setDrawTexts(not gameMapPanel:isDrawingTexts()) end, gameRootPanel)
g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
end

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

@ -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
return;
@ -255,17 +255,22 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
healthRect.setWidth((m_healthPercent / 100.0) * 25);
// draw
g_painter->setColor(Color::black);
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);
fillColor = Color(0x66, 0xcc, 0xff);
g_painter->drawFilledRect(healthRect);
if(drawFlags & Otc::DrawBars) {
g_painter->setColor(Color::black);
g_painter->drawFilledRect(backgroundRect);
m_nameCache.draw(textRect);
g_painter->setColor(fillColor);
g_painter->drawFilledRect(healthRect);
}
if(drawFlags & Otc::DrawNames) {
if(g_painter->getColor() != fillColor)
g_painter->setColor(fillColor);
m_nameCache.draw(textRect);
}
if(m_skull != Otc::SkullNone && m_skullTexture) {
g_painter->setColor(Color::white);

@ -48,7 +48,7 @@ public:
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView = nullptr);
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 setName(const std::string& name);

@ -557,6 +557,8 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<UIMap>("setAutoViewMode", &UIMap::setAutoViewMode);
g_lua.bindClassMemberFunction<UIMap>("setDrawFlags", &UIMap::setDrawFlags);
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>("setAnimated", &UIMap::setAnimated);
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>("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled);
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>("isLimitVisibleRangeEnabled", &UIMap::isLimitVisibleRangeEnabled);
g_lua.bindClassMemberFunction<UIMap>("isAnimating", &UIMap::isAnimating);

@ -204,7 +204,7 @@ void MapView::draw(const Rect& rect)
float verticalStretchFactor = rect.height() / (float)srcRect.height();
// 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) {
if(!creature->canBeSeen())
continue;
@ -218,7 +218,10 @@ void MapView::draw(const Rect& rect)
p.y = p.y * verticalStretchFactor;
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);
}
}

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

@ -51,6 +51,8 @@ public:
void setAutoViewMode(bool enable) { m_mapView->setAutoViewMode(enable); }
void setDrawFlags(Otc::DrawFlags drawFlags) { m_mapView->setDrawFlags(drawFlags); }
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 setAnimated(bool enable) { m_mapView->setAnimated(enable); }
void setKeepAspectRatio(bool enable);
@ -61,6 +63,8 @@ public:
bool isMultifloor() { return m_mapView->isMultifloor(); }
bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }
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 isAnimating() { return m_mapView->isAnimating(); }
bool isKeepAspectRatioEnabled() { return m_keepAspectRatio; }

Loading…
Cancel
Save