Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
haroldiedema committed Aug 25, 2024
0 parents commit 2be27a3
Show file tree
Hide file tree
Showing 27 changed files with 2,403 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish
on:
push:
tags: ["*"]

env:
SOLUTION_NAME: Umbra.Bejeweled
RELEASE_DIR: out/Release

jobs:
Build:
permissions:
contents: write
runs-on: windows-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true

- name: Set up .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.x

- name: Download Dalamud Latest
run: |
Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/latest.zip -OutFile latest.zip
Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\addon\Hooks\dev"
- name: Download Umbra Latest
run: |
Invoke-WebRequest -Uri https://raw.githubusercontent.com/una-xiv/umbra-dist/main/dist/Umbra/latest.zip -OutFile latest.zip
Expand-Archive -Force latest.zip "$env:AppData\XIVLauncher\installedPlugins\Umbra\dist"
- name: Restore solution
run: dotnet restore -r win ${{ env.SOLUTION_NAME }}.sln

- name: Build solution
run: |
dotnet restore -r win ${{ env.SOLUTION_NAME }}.sln
dotnet build --configuration Release
- name: Create plugin archive
run: Compress-Archive -Path ${{env.RELEASE_DIR}}* -DestinationPath ${{env.RELEASE_DIR}}/${{env.SOLUTION_NAME}}.zip

- name: Publish Plugin
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{env.RELEASE_DIR}}/${{env.SOLUTION_NAME}}.zip
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
out/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
.idea/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Bejeweled plugin for Umbra

Adds a Bejeweled minigame to Umbra.

## Download

1. Grab the latest version from the [Releases](https://github.com/una-xiv/Umbra.CounterSpyPlugin/releases) page.
2. Extract the ZIP file somewhere on your computer.
3. Open Umbra's settings, then go to the "Plugins" category.
4. Click on "Add plugin" and select the DLL file that you extracted in step 2.

## Adding the game to your toolbar.

Bejeweled is a widget. Once the plugin has been installed and Umbra has been restarted, you can add the game to your toolbar by clicking on the "Add widget" button in the toolbar and selecting "Bejeweled".
16 changes: 16 additions & 0 deletions Umbra.Bejeweled.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbra.Bejeweled", "Umbra.Bejeweled\Umbra.Bejeweled.csproj", "{53E266A9-368F-40F3-9A37-BB1ED7385B06}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{53E266A9-368F-40F3-9A37-BB1ED7385B06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{53E266A9-368F-40F3-9A37-BB1ED7385B06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{53E266A9-368F-40F3-9A37-BB1ED7385B06}.Release|Any CPU.ActiveCfg = Release|Any CPU
{53E266A9-368F-40F3-9A37-BB1ED7385B06}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
73 changes: 73 additions & 0 deletions Umbra.Bejeweled/Umbra.Bejeweled.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
</PropertyGroup>
<PropertyGroup>
<!-- <UmbraLibPath>Z:\FFXIV-plugins\una-xiv-plugins\Umbra\out\Release\</UmbraLibPath>-->
</PropertyGroup>
<PropertyGroup>
<UmbraLibPath>$([System.IO.Directory]::GetDirectories($(appdata)\XIVLauncher\installedPlugins\Umbra\)[0])\</UmbraLibPath>
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>..\out\$(Configuration)\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<Authors>Una</Authors>
<Company>Una XIV</Company>
<Version>1.0.0</Version>
<Description>A bejeweled game to kill time while waiting for queues.</Description>
<Copyright>(C)2024</Copyright>
<PackageProjectUrl>https://github.com/una-xiv/Umbra.BejeweledPlugin</PackageProjectUrl>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Reference Include="Umbra">
<HintPath>$(UmbraLibPath)Umbra.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Umbra.Common">
<HintPath>$(UmbraLibPath)Umbra.Common.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Umbra.Game">
<HintPath>$(UmbraLibPath)Umbra.Game.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Una.Drawing">
<HintPath>$(UmbraLibPath)Una.Drawing.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Dalamud">
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
</Project>
181 changes: 181 additions & 0 deletions Umbra.Bejeweled/src/BejeweledWidget.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
using System.Collections.Generic;
using Umbra.Bejeweled.Popup;
using Umbra.Common;
using Umbra.Widgets;

namespace Umbra.Bejeweled;

[ToolbarWidget("Bejeweled", "Bejeweled", "A mini-game of Bejeweled to play while you wait for your queue to pop.")]
internal sealed class BejeweledWidget(
WidgetInfo info,
string? guid = null,
Dictionary<string, object>? configValues = null
)
: DefaultToolbarWidget(info, guid, configValues)
{
/// <inheritdoc/>
public override BejeweledPopup Popup { get; } = new();

/// <inheritdoc/>
protected override IEnumerable<IWidgetConfigVariable> GetConfigVariables()
{
return [
new BooleanWidgetConfigVariable(
"EnableSound",
"Enable Sound Effects",
"Whether to enable sound effects.",
true
) { Category = "Game Options" },
new IntegerWidgetConfigVariable(
"Difficulty",
"Difficulty",
"The difficulty level of the game. Higher values increase the number of gem types. Changing this value will reset the game.",
2,
1,
4
) { Category = "Game Options" },
new IntegerWidgetConfigVariable(
"GemIcon1",
"Icon 1",
"The icon ID for the first gem type.",
21275,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"GemIcon2",
"Icon 2",
"The icon ID for the second gem type.",
21281,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"GemIcon3",
"Icon 3",
"The icon ID for the third gem type.",
21283,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"GemIcon4",
"Icon 4",
"The icon ID for the fourth gem type.",
21284,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"GemIcon5",
"Icon 5",
"The icon ID for the fifth gem type.",
21289,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"GemIcon6",
"Icon 6",
"The icon ID for the sixth gem type.",
21293,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"BombIcon",
"Bomb Icon",
"The icon ID for the bomb power-up.",
60728,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"HorizontalRocketIcon",
"Horizontal Rocket Icon",
"The icon ID for the horizontal rocket power-up.",
60727,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"VerticalRocketIcon",
"Vertical Rocket Icon",
"The icon ID for the vertical rocket power-up.",
60726,
0
) { Category = "Gem Icons" },
new IntegerWidgetConfigVariable(
"RainbowBombIcon",
"Rainbow Bomb Icon",
"The icon ID for the Rainbow Bomb power-up.",
60722,
0
) { Category = "Gem Icons" },
new StringWidgetConfigVariable(
"ButtonLabel",
"Button Label",
"The label for the button.",
Info.Name
) { Category = I18N.Translate("Widget.ConfigCategory.WidgetAppearance") },
new IntegerWidgetConfigVariable(
"ButtonIcon",
"Button Icon",
"The icon for the button.",
14,
0
) { Category = I18N.Translate("Widget.ConfigCategory.WidgetAppearance") },
..DefaultToolbarWidgetConfigVariables,
..SingleLabelTextOffsetVariables,
new IntegerWidgetConfigVariable("HiScore", "", null, 0, 0) { IsHidden = true },
];
}

private uint _lastHiScore;
private int _lastDifficulty;

/// <inheritdoc/>
protected override void Initialize()
{
SetIcon(14);
SetLabel(Info.Name);

_lastHiScore = (uint)GetConfigValue<int>("HiScore");
_lastDifficulty = GetConfigValue<int>("Difficulty");

Popup.HiScore = _lastHiScore;
Popup.Board.ColorCount = 2 + _lastDifficulty;

Popup.ResetGame();
}

public override string GetInstanceName()
{
return GetConfigValue<string>("ButtonLabel");
}

protected override void OnUpdate()
{
SetIcon((uint)GetConfigValue<int>("ButtonIcon"));
SetLabel(GetConfigValue<string>("ButtonLabel"));

int difficulty = GetConfigValue<int>("Difficulty");
if (difficulty != _lastDifficulty) {
_lastDifficulty = difficulty;
Popup.Board.ColorCount = 2 + difficulty;
Popup.Board.Reset();
}

Popup.Sound = GetConfigValue<bool>("EnableSound");
Popup.Board.EnableSfx = Popup.Sound;
Popup.Board.IconIds.GemType1 = (uint)GetConfigValue<int>("GemIcon1");
Popup.Board.IconIds.GemType2 = (uint)GetConfigValue<int>("GemIcon2");
Popup.Board.IconIds.GemType3 = (uint)GetConfigValue<int>("GemIcon3");
Popup.Board.IconIds.GemType4 = (uint)GetConfigValue<int>("GemIcon4");
Popup.Board.IconIds.GemType5 = (uint)GetConfigValue<int>("GemIcon5");
Popup.Board.IconIds.GemType6 = (uint)GetConfigValue<int>("GemIcon6");
Popup.Board.IconIds.Bomb = (uint)GetConfigValue<int>("BombIcon");
Popup.Board.IconIds.HorizontalRocket = (uint)GetConfigValue<int>("HorizontalRocketIcon");
Popup.Board.IconIds.VerticalRocket = (uint)GetConfigValue<int>("VerticalRocketIcon");
Popup.Board.IconIds.RainbowBomb = (uint)GetConfigValue<int>("RainbowBombIcon");

if (Popup.Board.Score > _lastHiScore) {
_lastHiScore = Popup.Board.Score;
SetConfigValue("HiScore", (int)Popup.HiScore);
}

base.OnUpdate();
}
}
Loading

0 comments on commit 2be27a3

Please sign in to comment.