1
Fork 0
mirror of https://github.com/redstrate/Auracite.git synced 2025-04-27 14:47:45 +00:00

Begin collecting some appearance data from the plugin

This commit is contained in:
Joshua Goins 2024-10-05 12:21:38 -04:00
parent 7ceaeb1798
commit 0c665679d4
8 changed files with 63 additions and 12 deletions

View file

@ -0,0 +1,31 @@
using System;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
namespace Auracite;
public class AppearanceStep : IStep
{
public event IStep.CompletedDelegate? Completed;
public void Run()
{
if (Plugin.ClientState.LocalPlayer != null)
{
Plugin.package.height = Plugin.ClientState.LocalPlayer.Customize[(int)CustomizeIndex.Height];
Plugin.package.bust_size = Plugin.ClientState.LocalPlayer.Customize[(int)CustomizeIndex.BustSize];
}
Completed?.Invoke();
}
public string StepName()
{
return "Appearance";
}
public string StepDescription()
{
return "No user action required.";
}
}

View file

@ -6,6 +6,8 @@ public interface IStep
{ {
public event CompletedDelegate Completed; public event CompletedDelegate Completed;
void Run();
string StepName(); string StepName();
string StepDescription(); string StepDescription();

View file

@ -18,6 +18,10 @@ public class PlaytimeStep : IStep, IDisposable
public event IStep.CompletedDelegate? Completed; public event IStep.CompletedDelegate? Completed;
public void Run()
{
}
public string StepName() public string StepName()
{ {
return "Playtime"; return "Playtime";

View file

@ -16,7 +16,7 @@ public sealed class Plugin : IDalamudPlugin
private readonly WindowSystem WindowSystem = new("Auracite"); private readonly WindowSystem WindowSystem = new("Auracite");
private readonly List<Type> _steps = private readonly List<Type> _steps =
[typeof(PlaytimeStep)]; [typeof(AppearanceStep), typeof(PlaytimeStep)];
private int _stepIndex; private int _stepIndex;
@ -25,6 +25,8 @@ public sealed class Plugin : IDalamudPlugin
public class Package public class Package
{ {
public string playtime; public string playtime;
public int height;
public int bust_size;
} }
public static Package? package; public static Package? package;
@ -78,6 +80,7 @@ public sealed class Plugin : IDalamudPlugin
} }
CurrentStep = (IStep)Activator.CreateInstance(_steps[_stepIndex])!; CurrentStep = (IStep)Activator.CreateInstance(_steps[_stepIndex])!;
CurrentStep.Completed += NextStep; CurrentStep.Completed += NextStep;
CurrentStep.Run();
} }
private void SendPackage() private void SendPackage()

View file

@ -5,19 +5,26 @@ pub struct Currencies {
pub gil: i64, pub gil: i64,
} }
#[derive(Default, Serialize)]
pub struct Appearance {
pub race: String,
pub subrace: String,
pub gender: String,
pub height: i32,
pub bust_size: i32
}
#[derive(Default, Serialize)] #[derive(Default, Serialize)]
pub struct CharacterData { pub struct CharacterData {
pub name: String, pub name: String,
pub world: String, pub world: String,
pub data_center: String, pub data_center: String,
pub race: String,
pub subrace: String,
pub gender: String,
pub city_state: String, pub city_state: String,
pub nameday: String, pub nameday: String,
pub guardian: String, pub guardian: String,
pub currencies: Currencies, pub currencies: Currencies,
pub playtime: String, pub playtime: String,
pub appearance: Appearance,
#[serde(skip)] #[serde(skip)]
pub face_url: String, pub face_url: String,

View file

@ -18,9 +18,9 @@ pub fn write_html(char_data: &CharacterData, file_path: &str) -> io::Result<()>
name => char_data.name, name => char_data.name,
world => char_data.world, world => char_data.world,
data_center => char_data.data_center, data_center => char_data.data_center,
race => char_data.race, race => char_data.appearance.race,
subrace => char_data.subrace, subrace => char_data.appearance.subrace,
gender => char_data.gender, gender => char_data.appearance.gender,
nameday => char_data.nameday, nameday => char_data.nameday,
city_state => char_data.city_state city_state => char_data.city_state
}) })

View file

@ -30,6 +30,8 @@ struct Args {
#[derive(Default, Deserialize, Clone)] #[derive(Default, Deserialize, Clone)]
struct Package { struct Package {
playtime: String, playtime: String,
height: i32,
bust_size: i32,
} }
#[derive(Clone)] #[derive(Clone)]
@ -109,6 +111,8 @@ fn main() {
let package = &*package.lock().unwrap(); let package = &*package.lock().unwrap();
char_data.playtime = package.playtime.parse().unwrap(); char_data.playtime = package.playtime.parse().unwrap();
char_data.appearance.height = package.height;
char_data.appearance.bust_size = package.bust_size;
} }
let serialized = serde_json::to_string(&char_data).unwrap(); let serialized = serde_json::to_string(&char_data).unwrap();

View file

@ -69,12 +69,12 @@ pub fn parse_lodestone(data: &str) -> CharacterData {
let inner_html = block_name.inner_html(); let inner_html = block_name.inner_html();
let captures = re.captures(&inner_html).unwrap(); let captures = re.captures(&inner_html).unwrap();
char_data.race = captures.get(1).unwrap().as_str().to_owned(); char_data.appearance.race = captures.get(1).unwrap().as_str().to_owned();
char_data.subrace = captures.get(2).unwrap().as_str().to_owned(); char_data.appearance.subrace = captures.get(2).unwrap().as_str().to_owned();
if captures.get(3).unwrap().as_str() == "" { if captures.get(3).unwrap().as_str() == "" {
char_data.gender = "Female".parse().unwrap(); char_data.appearance.gender = "Female".parse().unwrap();
} else { } else {
char_data.gender = "Male".parse().unwrap(); char_data.appearance.gender = "Male".parse().unwrap();
} }
} }
} else if name == "City-state" { } else if name == "City-state" {