Skip to content

Instantly share code, notes, and snippets.

View Deijin27's full-sized avatar

Deijin Deijin27

View GitHub Profile
@Deijin27
Deijin27 / getWindowsDpi.cs
Created March 20, 2023 17:37
Get the DPI. Works in WPF and WinForms
[DllImport("user32.dll")]
static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
static extern Int32 ReleaseDC(IntPtr hwnd, IntPtr hdc);
[DllImport("user32.dll")]
static extern bool IsProcessDPIAware();
[DllImport("gdi32.dll")]
@Deijin27
Deijin27 / ConquestJinkeiNamesExtract.cs
Created November 27, 2022 15:19
Extract names from conquest jinkei.dat
using System.Text;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var sjis = Encoding.GetEncoding("shift_jis");
using var br = new BinaryReader(File.OpenRead(@"C:\Users\Mia\Desktop\ConquestData\Jinkei.dat"));
using var tw = new StreamWriter(File.Create(@"C:\Users\Mia\Desktop\out.txt"));
var len = br.BaseStream.Length;
int count = 0;
@Deijin27
Deijin27 / conquest_eu_na_diff.xml
Created October 17, 2022 19:38
Difference between msg.dat in eu and na roms of pokemon conquest.
<?xml version="1.0" encoding="utf-8"?>
<!-- Difference between NA (before), and EU (after)-->
<changelist>
<type name="Messages">
<object name="Block_2_Msg_43">
<property name="Text">
<before>Sort by kingdom</before>
<after_>Sort by Pokédex No.</after_>
</property>
</object>
@Deijin27
Deijin27 / ideal_frog.cs
Last active October 3, 2022 19:42
Ideal way automapper could take normal classes.
internal class Program
{
static void Main(string[] args)
{
var config = new WrenConfig
{
Write = (vm, text) => Console.Write(text),
Error = (v, type, module, line, msg) => Console.Write($"{type} in module '{module}' on line '{line}', details: {msg}")
};
using var vm = new WrenVM(config);
@Deijin27
Deijin27 / WrenForeignClassReturn.cs
Created October 3, 2022 19:25
Shows how to return foreign class from foreign method.
internal class Program
{
static void Main(string[] args)
{
var config = new WrenConfig
{
Write = (vm, text) => Console.Write(text),
Error = (v, type, module, line, msg) => Console.Write($"{type} in module '{module}' on line '{line}', details: {msg}")
};
local total = 0
local scenario = 0
for sw in luanet.each(service.ScenarioWarrior:Retrieve(scenario):Enumerate()) do
if sw.GetScenarioPokemon(0) ~= 1100 then
local wid = sw.Warrior
local w = service.BaseWarrior:Retrieve(toInt(wid))
while w.RankUp ~= WarriorId.NoWarrior do
w = service.BaseWarrior.Retrieve(toInt(w.RankUp))
end
total = total + w.Capacity
@Deijin27
Deijin27 / PsleFrequencyAnalysis.fs
Created April 18, 2022 12:33
Create plot analysing frequency of values for a specific int index in psle files contained within eve files
open XPlot.Plotly;
open RanseiLink.Core.Models;
open System;
printfn "Loading EVE --------------------------"
let eve64 = new EVE(@"C:\Users\Mia\Desktop\00000064.eve")
let eve65 = new EVE(@"C:\Users\Mia\Desktop\00000065.eve")
let intIdx = 16
@Deijin27
Deijin27 / BushouDatNames.cs
Created April 7, 2022 11:27
Get names fro Bushou.dat conquest file
using System.Text;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var sjis = Encoding.GetEncoding("shift_jis");
using var br = new BinaryReader(File.OpenRead(@"C:\Users\Mia\Desktop\ConquestData\Bushou.dat"));
using var tw = new StreamWriter(File.Create(@"C:\Users\Mia\Desktop\out.txt"));
var len = 0x1770;
@Deijin27
Deijin27 / GroupPokemon.lua
Created March 3, 2022 20:34
Group pokemon by specific sections of bits (using some custom functions in util, and a custom version of lualinq)
require("lualinq")
require("util")
local modelService = using(service.Pokemon:Disposable())
local row = 2
local col = 24
local len = 8
local groups =
@Deijin27
Deijin27 / ScenarioNames.cs
Created January 4, 2022 21:57
Get names from Scenario.dat in pokemon conquest
using System.Text;
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var sjis = Encoding.GetEncoding("shift_jis");
using var br = new BinaryReader(File.OpenRead(@"C:\Users\Mia\Desktop\ConquestData\Scenario.dat"));
using var tw = new StreamWriter(File.Create(@"C:\Users\Mia\Desktop\out.txt"));
var len = br.BaseStream.Length;
int count = 0;