Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/lua/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ If a key does not exist, a default value is used:
- addonsSome(false): Can only change addons in list returned by `getAllowedAddons`
- swapping(false): Swap places
- playerState(false): Change player slots (add/change AI, ...)
- ownNation, ownColor, ownTeam (all true): Change values player
- aiNation, aiColor, aiTeam (all true): Change values of AI
- ownNation, ownColor, ownTeam, ownPortrait (all true): Change values player
- aiNation, aiColor, aiTeam, aiPortrait (all true): Change values of AI

```lua
function getAllowedChanges()
Expand Down
12 changes: 12 additions & 0 deletions libs/s25main/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ ctrlDeepening* Window::AddColorDeepening(unsigned id, const DrawPoint& pos, cons
return AddCtrl(new ctrlColorDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, fillColor));
}

ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
ITexture* image)
{
return AddCtrl(new ctrlImageDeepening(this, id, ScaleIf(pos), ScaleIf(size), tc, image));
}

ctrlDeepening* Window::AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
glArchivItem_Bitmap* image)
{
return AddImageDeepening(id, pos, size, tc, static_cast<ITexture*>(image));
}

ctrlEdit* Window::AddEdit(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
unsigned short maxlength, bool password, bool disabled, bool notify)
{
Expand Down
5 changes: 5 additions & 0 deletions libs/s25main/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ class Window
FontStyle style = FontStyle::CENTER | FontStyle::VCENTER);
ctrlDeepening* AddColorDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
unsigned fillColor);
ctrlDeepening* AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
ITexture* image);
ctrlDeepening* AddImageDeepening(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc,
glArchivItem_Bitmap* image);

ctrlEdit* AddEdit(unsigned id, const DrawPoint& pos, const Extent& size, TextureColor tc, const glFont* font,
unsigned short maxlength = 0, bool password = false, bool disabled = false, bool notify = false);
ctrlGroup* AddGroup(unsigned id);
Expand Down
1 change: 1 addition & 0 deletions libs/s25main/controls/controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ctrlGroup.h"
#include "ctrlImage.h"
#include "ctrlImageButton.h"
#include "ctrlImageDeepening.h"
#include "ctrlList.h"
#include "ctrlMapSelection.h"
#include "ctrlMultiSelectGroup.h"
Expand Down
17 changes: 17 additions & 0 deletions libs/s25main/controls/ctrlImageDeepening.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later

#include "ctrlImageDeepening.h"
#include <ogl/ITexture.h>

ctrlImageDeepening::ctrlImageDeepening(Window* parent, unsigned id, DrawPoint pos, const Extent& size, TextureColor tc,
ITexture* image)
: ctrlDeepening(parent, id, pos, size, tc), ctrlBaseImage(image)
{}

void ctrlImageDeepening::DrawContent() const
{
// Adding of origin compensates for its substraction inside ITexture::Draw()
DrawImage(Rect(GetDrawPos() + GetImage()->GetOrigin(), GetSize()));
}
19 changes: 19 additions & 0 deletions libs/s25main/controls/ctrlImageDeepening.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2005 - 2025 Settlers Freaks (sf-team at siedler25.org)
//
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "controls/ctrlDeepening.h"
#include "ctrlBaseImage.h"

/// Image Deepening
class ctrlImageDeepening : public ctrlDeepening, public ctrlBaseImage
{
public:
ctrlImageDeepening(Window* parent, unsigned id, DrawPoint pos, const Extent& size, TextureColor tc,
ITexture* image);

protected:
void DrawContent() const override;
};
17 changes: 13 additions & 4 deletions libs/s25main/desktops/dskGameLobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,21 @@ void dskGameLobby::UpdatePlayerRow(const unsigned row)
bool allowNationChange = allowPlayerChange;
bool allowColorChange = allowPlayerChange;
bool allowTeamChange = allowPlayerChange;
bool allowPortaitChange = allowPlayerChange;
if(lua)
{
if(localPlayerId_ == row)
{
allowNationChange &= lua->IsChangeAllowed("ownNation", true);
allowColorChange &= lua->IsChangeAllowed("ownColor", true);
allowTeamChange &= lua->IsChangeAllowed("ownTeam", true);
allowPortaitChange &= lua->IsChangeAllowed("ownPortrait", true);
} else
{
allowNationChange &= lua->IsChangeAllowed("aiNation", true);
allowColorChange &= lua->IsChangeAllowed("aiColor", true);
allowTeamChange &= lua->IsChangeAllowed("aiTeam", true);
allowPortaitChange &= lua->IsChangeAllowed("aiPortrait", true);
}
}

Expand All @@ -461,8 +464,12 @@ void dskGameLobby::UpdatePlayerRow(const unsigned row)
NormalFont, COLOR_YELLOW);

const auto& portrait = Portraits[player.portraitIndex];
group->AddImageButton(ID_btPortrait, DrawPoint(315, cy), Extent(34, 22), tc,
LOADER.GetImageN(portrait.resourceId, portrait.resourceIndex), _(portrait.name));
if(allowPortaitChange)
group->AddImageButton(ID_btPortrait, DrawPoint(315, cy), Extent(34, 22), tc,
LOADER.GetImageN(portrait.resourceId, portrait.resourceIndex), _(portrait.name));
else
group->AddImageDeepening(ID_btPortrait, DrawPoint(315, cy), Extent(34, 22), tc,
LOADER.GetImageN(portrait.resourceId, portrait.resourceIndex));

if(allowColorChange)
group->AddColorButton(ID_btColor, DrawPoint(354, cy), Extent(30, 22), tc, 0);
Expand Down Expand Up @@ -965,9 +972,11 @@ void dskGameLobby::ChangePortrait(const unsigned player, const unsigned portrait
{
RTTR_Assert(portraitIndex < Portraits.size());
const auto& portrait = Portraits[portraitIndex];
auto* ctrl = GetCtrl<ctrlGroup>(ID_grpPlayerStart + player)->GetCtrl<ctrlImageButton>(ID_btPortrait);
auto* ctrl = GetCtrl<ctrlGroup>(ID_grpPlayerStart + player)->GetCtrl<ctrlBaseImage>(ID_btPortrait);
ctrl->SetImage(LOADER.GetImageN(portrait.resourceId, portrait.resourceIndex));
ctrl->SetTooltip(_(portrait.name));
auto* ctrlButton = GetCtrl<ctrlGroup>(ID_grpPlayerStart + player)->GetCtrl<ctrlImageButton>(ID_btPortrait);
if(ctrlButton)
ctrlButton->SetTooltip(_(portrait.name));
}

void dskGameLobby::ChangePing(unsigned playerId)
Expand Down
Loading