Skip to content

Commit

Permalink
feat: Opacity effect and missile in options (#676)
Browse files Browse the repository at this point in the history
* feat: Opacity effect and missile in options

issue of "roriscrave" in otland

* OTC naming convention

OTC naming convention

* test review conde2

- with bug (opacity in tile)

* fix: capital letter

* line

* Update modules/client_options/general.otui

Co-authored-by: Caio Santoro dos Santos <61211407+csantbr@users.noreply.github.com>

* Fix: Opacity tile

---------

Co-authored-by: Caio Santoro dos Santos <61211407+csantbr@users.noreply.github.com>
  • Loading branch information
kokekanon and csantbr authored Dec 13, 2023
1 parent e0a21e0 commit 295db73
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 1 deletion.
32 changes: 32 additions & 0 deletions modules/client_options/general.otui
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,38 @@ Panel
margin-top: 3
minimum: 1
maximum: 9

Label
id: setEffectAlphaLabel
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 12

OptionScrollbar
id: setEffectAlphaScroll
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 3
minimum: 10
maximum: 100

Label
id: setMissileAlphaLabel
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 12

OptionScrollbar
id: setMissileAlphaScroll
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 3
minimum: 10
maximum: 100

Label
id: chooseCrosshairLabel
Expand Down
11 changes: 10 additions & 1 deletion modules/client_options/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ local defaultOptions = {
asyncTxtLoading = false,
creatureInformationScale = 0,
staticTextScale = 0,
animatedTextScale = 0
animatedTextScale = 0,
setEffectAlphaScroll = 100 ,
setMissileAlphaScroll = 100 ,
}

local optionsWindow
Expand Down Expand Up @@ -352,6 +354,13 @@ function setOption(key, value, force)
local fadeMode = value == 1
graphicsPanel:getChildById('floorFading'):setEnabled(fadeMode)
graphicsPanel:getChildById('floorFadingLabel'):setEnabled(fadeMode)

elseif key == 'setEffectAlphaScroll' then
g_client.setEffectAlpha(value/100)
generalPanel:getChildById('setEffectAlphaLabel'):setText(tr('Opacity Effect: %s%%', value))
elseif key == 'setMissileAlphaScroll' then
g_client.setMissileAlpha(value/100)
generalPanel:getChildById('setMissileAlphaLabel'):setText(tr('Opacity Missile: %s%%', value))
end

-- change value for keybind updates
Expand Down
8 changes: 8 additions & 0 deletions src/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ class Client : public ApplicationDrawEvents

UIMapPtr getMapWidget() { return m_mapWidget; }

float getEffectAlpha() const { return m_effectAlpha; }
void setEffectAlpha(float v) { m_effectAlpha = v; }

float getMissileAlpha() const { return m_missileAlpha; }
void setMissileAlpha(float v) { m_missileAlpha = v; }

private:
UIMapPtr m_mapWidget;
float m_effectAlpha{ PlatformWindow::DEFAULT_DISPLAY_DENSITY };
float m_missileAlpha{ PlatformWindow::DEFAULT_DISPLAY_DENSITY };
};

extern Client g_client;
3 changes: 3 additions & 0 deletions src/client/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <framework/core/graphicalapplication.h>
#include "game.h"
#include "map.h"
#include <client/client.h>

void Effect::draw(const Point& dest, bool drawThings, LightView* lightView)
{
Expand Down Expand Up @@ -73,6 +74,8 @@ void Effect::draw(const Point& dest, bool drawThings, LightView* lightView)
m_drawConductor.order = DrawOrder::FOURTH;
}

if (drawThings && g_client.getEffectAlpha() < 1.f)
g_drawPool.setOpacity(g_client.getEffectAlpha(), true);
getThingType()->draw(dest, 0, xPattern, yPattern, 0, animationPhase, Color::white, drawThings, lightView, m_drawConductor);
}

Expand Down
4 changes: 4 additions & 0 deletions src/client/missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
#include "map.h"
#include "thingtypemanager.h"
#include "tile.h"
#include <client/client.h>

void Missile::draw(const Point& dest, bool drawThings, LightView* lightView)
{
if (!canDraw() || isHided())
return;

const float fraction = m_animationTimer.ticksElapsed() / m_duration;

if (drawThings && g_client.getMissileAlpha() < 1.f)
g_drawPool.setOpacity(g_client.getMissileAlpha(), true);
getThingType()->draw(dest + m_delta * fraction * g_drawPool.getScaleFactor(), 0, m_numPatternX, m_numPatternY, 0, 0, Color::white, drawThings, lightView, m_drawConductor);
}

Expand Down
6 changes: 6 additions & 0 deletions src/framework/luafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <framework/platform/platform.h>
#include <framework/stdext/net.h>
#include <framework/util/crypt.h>
#include <client/client.h>

#ifdef FRAMEWORK_GRAPHICS
#include "framework/graphics/particleeffect.h"
Expand Down Expand Up @@ -322,6 +323,11 @@ void Application::registerLuaFunctions()
g_lua.bindSingletonFunction("g_app", "setCreatureInformationScale", &GraphicalApplication::setCreatureInformationScale, &g_app);
g_lua.bindSingletonFunction("g_app", "setAnimatedTextScale", &GraphicalApplication::setAnimatedTextScale, &g_app);
g_lua.bindSingletonFunction("g_app", "setStaticTextScale", &GraphicalApplication::setStaticTextScale, &g_app);

// Client
g_lua.registerSingletonClass("g_client");

This comment has been minimized.

Copy link
@BenDol

BenDol Dec 13, 2023

Collaborator

These should be registered in the client luafunctions.h rather than framework

This comment has been minimized.

Copy link
@kokekanon

kokekanon Dec 14, 2023

Author Collaborator

Sorry, I just read this comment.

by luafunctions.h you mean luafunctions.cpp in dir "client"

image

@BenDol

This comment has been minimized.

Copy link
@BenDol

BenDol via email Dec 14, 2023

Collaborator

This comment has been minimized.

Copy link
@kokekanon

kokekanon Dec 14, 2023

Author Collaborator
g_lua.bindSingletonFunction("g_client", "setEffectAlpha", &Client::setEffectAlpha, &g_client);
g_lua.bindSingletonFunction("g_client", "setMissileAlpha", &Client::setMissileAlpha, &g_client);

// PlatformWindow
g_lua.registerSingletonClass("g_window");
Expand Down

0 comments on commit 295db73

Please sign in to comment.