Browse Source

[SplashTexts] [2.0.2.1] Creation of SplashTexts

Zariteis 4 years ago
parent
commit
ddca77b9d0

BIN
SplashTexts/Assets/roguelandsTitle.png


BIN
SplashTexts/Assets/roguelandsTitleL.png


BIN
SplashTexts/Assets/roguelandsTitleL2.png


+ 15 - 0
SplashTexts/Core.cs

@@ -0,0 +1,15 @@
+using GadgetCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using UnityEngine;
+
+namespace SplashTexts
+{
+  internal static class Core
+  {
+    public static GadgetLogger logger;
+    public static Texture defaultTitleTexture;
+  }
+}

+ 3 - 0
SplashTexts/Manifest.ini

@@ -0,0 +1,3 @@
+[Metadata]
+Name=Splash Texts
+Assembly=SplashTexts.dll

+ 1 - 0
SplashTexts/ModInfo.txt

@@ -0,0 +1 @@
+A mod that adds random splash texts to the main menu.

+ 10 - 0
SplashTexts/Properties/AssemblyInfo.cs

@@ -0,0 +1,10 @@
+using System.Reflection;
+using static SplashTexts.SplashTexts;
+
+[assembly: AssemblyProduct("Platform Block Mod")] //Set this to the full name of the mod including spaces.
+[assembly: AssemblyTitle("Platform Block")] //This is only used when mousing over a dll file in Windows explorer.
+[assembly: AssemblyDescription("A Gadget mod for Roguelands, adding a platform block.")] //This is a short description for your mod's assembly.
+[assembly: AssemblyCompany("")] //Set this to your name/nickname and/or website
+[assembly: AssemblyCopyright("© 2021 Zariteis. All rights reserved.")] //Set this to your copyright name.
+[assembly: AssemblyVersion(MOD_VERSION)]
+[assembly: AssemblyFileVersion(MOD_VERSION)]

+ 8 - 0
SplashTexts/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "SplashTexts": {
+      "commandName": "Executable",
+      "executablePath": "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Roguelands\\Roguelands.exe"
+    }
+  }
+}

+ 15 - 0
SplashTexts/README.txt

@@ -0,0 +1,15 @@
+In addition to changing all references to "Template" this and that to a more appropriate name,
+you need to add a file called "GamePaths.xml" to the folder ABOVE where you put this template, with the following content:
+
+<?xml version="1.0" encoding="utf-8"?>
+<Project>
+  <PropertyGroup>
+    <!-- Set this full path to your game folder. Must contain a slash at the end. -->
+    <GamePath>C:\Program Files (x86)\Steam\steamapps\common\Roguelands\</GamePath>
+
+    <!-- Set this partial path to the game's Managed folder. Must contain a slash at the end. -->
+    <ManagedFolder>Roguelands_Data\Managed\</ManagedFolder>
+  </PropertyGroup>
+</Project>
+
+Note that `GamePath` may need to be changed, depending on the nature of your installation.

+ 141 - 0
SplashTexts/SplashTexts.cs

@@ -0,0 +1,141 @@
+using UnityEngine;
+using GadgetCore.API;
+using UnityEngine.SceneManagement;
+using GadgetCore.API.ConfigMenu;
+using System;
+using System.Collections.Generic;
+
+namespace SplashTexts
+{
+  [Gadget("SplashTexts")]
+  public class SplashTexts : Gadget<SplashTexts>
+  {
+    public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
+    public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
+
+    public override IGadgetConfigMenu GetConfigMenu() { return null; }
+
+    public override string GetModDescription()
+    {
+      return "A mod that adds random splash texts to the main menu.";
+    }
+
+    protected override void Initialize()
+    {
+      Logger.Log("Platform Block v" + Info.Mod.Version);
+      Core.logger = Logger;
+      SceneManager.sceneLoaded += OnSceneLoaded;
+      ChangeMenuText();
+    }
+
+    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
+    {
+      if (scene.buildIndex == 0)
+      {
+        ChangeMenuText();
+      }
+    }
+
+
+    private static Texture2D texture2D = GadgetCoreAPI.LoadTexture2D("roguelandsTitle.png");
+    private static Texture2D texture2DL = GadgetCoreAPI.LoadTexture2D("roguelandsTitleL2.png");
+
+    private static void ChangeMenuText()
+    {
+      try
+      {
+        var titleElement = GameObject.Find("MAIN").transform.Find("-").gameObject;
+        var renderer = titleElement.GetComponent<Renderer>();
+        if (Core.defaultTitleTexture == null)
+          Core.defaultTitleTexture = renderer.material.mainTexture;
+        if (random.Next(2) == 0)
+        {
+          renderer.material = new Material(Shader.Find("Unlit/Transparent"))
+          {
+            mainTexture = texture2DL
+          };
+        }
+        else if (random.Next(2) == 0)
+        {
+          renderer.material = new Material(Shader.Find("Unlit/Transparent"))
+          {
+            mainTexture = texture2D
+          };
+        }
+        else
+        {
+          renderer.material = new Material(Shader.Find("Unlit/Transparent"))
+          {
+            mainTexture = Core.defaultTitleTexture
+          };
+        }
+
+
+        var text = GetText();
+
+        var textElement = GameObject.Find("MAIN").transform.Find("-").Find("txtALPHA").gameObject;
+        var textElementShadow = textElement.transform.Find("txt0").gameObject;
+
+        textElement.GetComponent<TextMesh>().color = SpliceColor(ref text);
+
+        var shadowText = SpliceShadow(ref text);
+
+        textElement.GetComponent<TextMesh>().text = text;
+        textElementShadow.GetComponent<TextMesh>().text = shadowText;
+      }
+      catch (Exception e) { Core.logger.LogConsole(e); }
+    }
+
+    private static System.Random random = new System.Random();
+
+    private static string GetText()
+    {
+      List<string> texts = new List<string>();
+      texts.Add("v1.5.1 Deluxe");
+      texts.Add("#C#AAAAFF#Infinity Edition");
+      texts.Add("Gadget Core " + GadgetCoreAPI.GetFullVersion() + " Edition");
+      texts.Add("There are mods?");
+      texts.Add("1 + 5 = 1#S#1 + 5 = 6");
+      texts.Add("v1.5.1#S#v1.5");
+      texts.Add("Magicite 2");
+      texts.Add("I wouldn't talk to the guy with the pickaxe.");
+      return texts[random.Next(texts.Count)];
+    }
+
+    private static Color SpliceColor(ref string s)
+    {
+      if (s.StartsWith("#C#"))
+      {
+        try
+        {
+          var ar = s.Split(new char[] { '#' }, 4);
+          s = ar[3];
+          if (ar[2].Length == 6)
+          {
+            var i1 = Convert.ToInt32(ar[2].Substring(0, 2), 16);
+            var i2 = Convert.ToInt32(ar[2].Substring(2, 2), 16);
+            var i3 = Convert.ToInt32(ar[2].Substring(4, 2), 16);
+            return new Color(((float)i1) / 0xFF, ((float)i2) / 0xFF, ((float)i3) / 0xFF);
+          }
+        }
+        catch { }
+      }
+      return new Color(((float)0xFF) / 0xFF, ((float)0xD7) / 0xFF, ((float)0x31) / 0xFF);
+    }
+
+    private static string SpliceShadow(ref string s)
+    {
+      if (s.Contains("#S#"))
+      {
+        try
+        {
+          var ar = s.Split(new string[] { "#S#" }, 2, StringSplitOptions.None);
+          s = ar[0];
+          return ar[1];
+        }
+        catch { }
+      }
+      return s;
+    }
+  }
+}

+ 209 - 0
SplashTexts/SplashTexts.csproj

@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project Sdk="Microsoft.NET.Sdk">
+  <ImportGroup>
+    <Import Project="../GamePaths.xml" />
+  </ImportGroup>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProjectGuid>{91AB81DE-EAEE-47D1-93DD-541179208219}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MoreLights</RootNamespace>
+    <AssemblyName>SplashTexts</AssemblyName>
+    <TargetFrameworks>net35</TargetFrameworks>
+    <FileAlignment>512</FileAlignment>
+    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
+    <Configurations>Release</Configurations>
+    <Authors>Zariteis</Authors>
+    <ApplicationIcon />
+    <StartupObject />
+    <Platforms>x86</Platforms>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <PlatformTarget>x86</PlatformTarget>
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net35|x86'">
+    <NoWarn>1701;1702</NoWarn>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="0Harmony">
+      <HintPath>$(GamePath)$(ManagedFolder)0Harmony.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="Assembly-CSharp">
+      <HintPath>$(GamePath)$(ManagedFolder)Assembly-CSharp.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="GadgetCore">
+      <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="UnityEngine">
+      <HintPath>$(GamePath)$(ManagedFolder)UnityEngine.dll</HintPath>
+      <Private>false</Private>
+    </Reference>
+    <Reference Include="WindowsBase" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="ModInfo.txt">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+  <UsingTask TaskName="GetFileVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+    <ParameterGroup>
+      <AssemblyPath ParameterType="System.String" Required="true" />
+      <Version ParameterType="System.String" Output="true" />
+      <TrimmedVersion ParameterType="System.String" Output="true" />
+    </ParameterGroup>
+    <Task>
+      <Using Namespace="System.Diagnostics" />
+      <Using Namespace="System.Text" />
+      <Using Namespace="System.Linq" />
+      <Code Type="Fragment" Language="cs">
+        <![CDATA[
+      this.Version = FileVersionInfo.GetVersionInfo(this.AssemblyPath).FileVersion;  
+      this.TrimmedVersion = this.Version.Split('.').TakeWhile(x => !x.Equals("0")).Aggregate(new StringBuilder(), (a, b) => { if (a.Length > 0) a.Append("."); a.Append(b); return a; }).ToString();
+      if (this.TrimmedVersion.IndexOf('.') == -1) this.TrimmedVersion += ".0";
+    ]]>
+      </Code>
+    </Task>
+  </UsingTask>
+  <Target Name="PostBuild" AfterTargets="PostBuildEvent">
+    <GetFileVersion AssemblyPath="$(TargetPath)">
+      <Output TaskParameter="Version" PropertyName="ModFullVersion" />
+      <Output TaskParameter="TrimmedVersion" PropertyName="AssemblyFileVersion" />
+    </GetFileVersion>
+    <ItemGroup>
+      <OldZip Include="$(TargetDir)$(AssemblyName)_v*.zip" />
+      <OldZip Include="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v*.zip" />
+    </ItemGroup>
+    <Delete Files="@(OldZip)" />
+    <MakeDir Directories="$(TargetDir)..\BuildCache\" />
+    <ZipDirectory SourceDirectory="$(TargetDir)" DestinationFile="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <Copy SourceFiles="$(TargetDir)..\BuildCache\$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <RemoveDir Directories="$(TargetDir)..\BuildCache\" />
+    <MakeDir Directories="$(GamePath)GadgetCore\Mods\" />
+    <Copy SourceFiles="$(TargetDir)$(AssemblyName)_v$(AssemblyFileVersion).zip" DestinationFiles="$(GamePath)GadgetCore\Mods\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+    <Message Importance="High" Text="Mod Exported to $(GamePath)GadgetCore\Mods\$(AssemblyName)_v$(AssemblyFileVersion).zip" />
+  </Target>
+  <ItemGroup>
+    <None Update="Assets\cGreenLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\charBG.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cOrangeLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cPurpleLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cWhiteLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\cYellowLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\First\one">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iAirCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iEarthCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iFireCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iGreenLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iOrangeLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iPurpleLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iWaterCore.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iWhiteLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\iYellowLamp.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\one">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\roguelandsTitle.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\roguelandsTitleL.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Assets\roguelandsTitleL2.png">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+    <None Update="Manifest.ini">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System">
+      <Private>false</Private>
+      <SpecificVersion>true</SpecificVersion>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Data">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Drawing">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.IO.Compression.FileSystem">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Numerics">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Runtime.Serialization">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Xml">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Update="System.Xml.Linq">
+      <EmbedInteropTypes>false</EmbedInteropTypes>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Patches\" />
+  </ItemGroup>
+</Project>