﻿macro = {
	description = "show character window? dummy character not counts"
	definition = "ShowCharacterWindow"
	replace_with = "And(Not(RUI_Ch_AGOT_macro_05), Not(RUI_Ch_GDHJ_macro_02))"
}

macro = {
	description = "Has At least 1 relation of this type"
	definition = "HasRelation(Type)"
	replace_with = "GreaterThanOrEqualTo_int32( NumOfRelation(Type), '(int32)1' )"
}

macro = {
	description = "Has At least 2 relation of this type"
	definition = "HasRelations(Type)"
	replace_with = "GreaterThanOrEqualTo_int32( NumOfRelation(Type), '(int32)2' )"
}

macro = {
	description = "num of relation of this type"
	definition = "NumOfRelation(Type)"
	replace_with = "GetDataModelSize( CharacterWindow.GetRelationsOfType( GetRelation( Type ) ) )"
}

macro = {
	description = "show str with () if not empty"
	definition = "ShowStringWithParentheses(String)"
	replace_with = "ConcatIfNeitherEmpty(ConcatIfNeitherEmpty('(', String), ')')"
}

macro = {
	description = "show number with () if more than 0"
	definition = "ShowNumberWithParentheses(Number)"
	replace_with = "SelectLocalization(GreaterThanOrEqualTo_int32( Number, '(int32)1' ), Concatenate('(', Concatenate( GetString_int32(Number) , ')') ), '')"
}

macro = {
	description = "show relation number if more than 0"
	definition = "RealtionTabCount(Type)"
	replace_with = "ShowNumberWithParentheses(NumOfRelation(Type))"
}

macro = {
	description = "show size of datamodel if more than 0"
	definition = "DataModelTabCount(DataModel)"
	replace_with = "ShowNumberWithParentheses(GetDataModelSize(DataModel))"
}

macro = {
	description = "show tab items number if more than 0"
	definition = "TabItemsCount(Type)"
	replace_with = "ShowNumberWithParentheses(CharacterWindow.GetTabItemsCount(Type))"
}

macro = {
    description = "Returns the int32 as a string."
    definition = "GetString_int32(Arg0)"
    replace_with = "GuiScope.AddScope( 'number', MakeScopeValue(IntToFixedPoint(Arg0))).Custom('NumberToString')"
}

# anime character's don't sit no matter at what age, nor dragons
macro = {
	description = "Should this character show sitting portrait?"
	definition = "ShowSeatPortrait"
	replace_with = "And(LessThan_int32( Character.GetAge, '(int32)1' ), And(Not(RUI_Ch_HJCL_macro_01), Not(RUI_Ch_AGOT_macro_02)))"
}

macro = {
	description = "Should this character show bigger portrait?"
	definition = "ShowTorsoPortrait"
	replace_with = "VariableSystem.Exists( 'RUI_Ch_portrait_torso' )"
}

macro = {
	description = "Does this character have vassal tab?"
	definition = "VassalTabEnabled"
	replace_with = "And(GreaterThanOrEqualTo_int32( CharacterWindow.GetTabItemsCount( 'subjects' ), '(int32)1' ), RUI_Ch_AGOT_macro_06)"
}

macro = {
	description = "Does this character have court tab?"
	definition = "CourtTabEnabled"
	replace_with = "And(GreaterThanOrEqualTo_int32( CharacterWindow.GetTabItemsCount( 'court' ), '(int32)1' ), RUI_Ch_AGOT_macro_06)"
}

macro = {
	description = "Does this character have relation tab?"
	definition = "RelationTabEnabled"
	replace_with = "And(Not(RUI_Ch_AGOT_macro_05), Or( Or( GreaterThanOrEqualTo_int32( CharacterWindow.GetTabItemsCount( 'relations' ), '(int32)1' ), Character.IsPlayerInteractionShown( 'offer_guardianship_interaction' ) ), Or( Character.IsPlayerInteractionShown( 'offer_ward_interaction' ), Character.IsPlayerInteractionShown( 'educate_child_interaction' ) ) ))"
}

macro = {
	description = "Does this character have politic tab?"
	definition = "PoliticTabEnabled"
	replace_with = "Not(RUI_Ch_AGOT_macro_02)"
}

macro = {
	description = "Does this character have diplomacy section in politics tab?"
	definition = "ShowDiplomacyItems"
	replace_with = "And(And(Not( IsDataModelEmpty( CharacterWindow.GetDiplomacyItems ) ), RUI_Ch_AGOT_macro_06), RUI_Ch_OBFS_macro_05)"
}

macro = {
	description = "Does this character have title section in politics tab?"
	definition = "ShowTitleItems"
	replace_with = "And(And(Not( IsDataModelEmpty( CharacterWindow.GetTitles ) ), RUI_Ch_AGOT_macro_06), RUI_Ch_OBFS_macro_16)"
}

macro = {
	description = "Does this character have claims section in politics tab?"
	definition = "ShowClaimItems"
	replace_with = "And(And(Not( IsDataModelEmpty( CharacterWindow.GetClaims ) ), RUI_Ch_AGOT_macro_06), RUI_Ch_OBFS_macro_16)"
}

macro = {
	description = "should show ward row for this character?"
	definition = "ShowWardRow(TargetCharacter)"
	replace_with = "Or( HasRelation( 'ward' ), Or( TargetCharacter.IsPlayerInteractionShown( 'educate_child_interaction' ), TargetCharacter.IsPlayerInteractionShown( 'offer_ward_interaction' ) ) )"
}

macro = {
	description = "should show guardian row for this character?"
	definition = "ShowGuardianRow(TargetCharacter)"
	replace_with = "Or( HasRelation( 'guardian' ), Or( TargetCharacter.IsPlayerInteractionShown( 'educate_child_interaction' ), TargetCharacter.IsPlayerInteractionShown( 'offer_guardianship_interaction' ) ) )"
}

macro = {
	description = "return true"
	definition = "True"
	replace_with = "EqualTo_CFixedPoint('(CFixedPoint)0', '(CFixedPoint)0')"
}

macro = {
	description = "return False"
	definition = "False"
	replace_with = "Not(True)"
}
# traits
macro = {
	description = "hide RUI_Ch_filter_education_trait if toggled"
	definition = "RUI_Ch_filter_education_trait"
	replace_with = "Or( Not( VariableSystem.Exists( 'RUI_Ch_filter_education_trait' ) ), And( Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'education_stewardship_1' ).GetTraitCategoryLabel ) ), Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'bossy' ).GetTraitCategoryLabel ) ) ) )"
}
macro = {
	description = "hide RUI_Ch_filter_lifestyle_trait if toggled"
	definition = "RUI_Ch_filter_lifestyle_trait"
	replace_with = "Or( Not( VariableSystem.Exists( 'RUI_Ch_filter_lifestyle_trait' ) ), Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'scholar' ).GetTraitCategoryLabel ) ) )"
}
macro = {
	description = "hide RUI_Ch_filter_fame_trait if toggled"
	definition = "RUI_Ch_filter_fame_trait"
	replace_with = "Or( Not( VariableSystem.Exists( 'RUI_Ch_filter_fame_trait' ) ), Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'bastard' ).GetTraitCategoryLabel ) ) )"
}
macro = {
	description = "hide RUI_Ch_filter_health_trait if toggled"
	definition = "RUI_Ch_filter_health_trait"
	replace_with = "Or( Not( VariableSystem.Exists( 'RUI_Ch_filter_health_trait' ) ), Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'ill' ).GetTraitCategoryLabel ) ) )"
}
macro = {
	description = "hide RUI_Ch_filter_physical_trait if toggled"
	definition = "RUI_Ch_filter_physical_trait"
	replace_with = "Or( Not( VariableSystem.Exists( 'RUI_Ch_filter_physical_trait' ) ), Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'strong' ).GetTraitCategoryLabel ) ) )"
}
macro = {
	description = "hide RUI_Ch_filter_commander_trait if toggled"
	definition = "RUI_Ch_filter_commander_trait"
	replace_with = "Or( Not( VariableSystem.Exists( 'RUI_Ch_filter_commander_trait' ) ), Not( ObjectsEqual( Trait.GetTraitCategoryLabel, GetTrait( 'cautious_leader' ).GetTraitCategoryLabel ) ) )"
}
# Trait.HasFlag not work yet
macro = {
	description = "should not be shown as trait"
	definition = "RUI_Ch_hidden_trait"
	replace_with = "RUI_Ch_HIBL_macro_01"
}
#macro = {
#	description = "count of hidden trait"
#	definition = "RUI_Ch_hidden_trait_count"
#	replace_with = "FixedPointToInt(GuiScope.SetRoot( Character.MakeScope ).ScriptValue('hidden_trait_counter'))"
#}
macro = {
	description = "trait count, exclude hidden ones"
	definition = "RUI_Ch_trait_count"
	replace_with = "FixedPointToInt(GuiScope.SetRoot( Character.MakeScope ).ScriptValue('non_hidden_trait_counter'))"
}

macro = {
	description = "CharacterWindow has children"
	definition = "HasChildren"
	replace_with = "GreaterThanOrEqualTo_int32( GetDataModelSize( CharacterWindow.GetChildren ), '(int32)1' )"
}

macro = {
	description = "CharacterWindow has sibiling"
	definition = "HasSibilings"
	replace_with = "GreaterThanOrEqualTo_int32( GetDataModelSize( CharacterWindow.GetSiblings ), '(int32)1' )"
}


macro = {
	description = "ceil int32 divide"
	definition = "CeilDivide_int32(X,Y)"
	replace_with = "Select_int32(EqualTo_int32(Modulo_int32(X,Y),'(int32)0'), Divide_int32(X,Y),Add_int32(Divide_int32(X,Y),'(int32)1'))"
}

macro = {
	description = "num of resource type"
	definition = "ResourceTypeCount(RelativePositionToResource)"
	replace_with = "RelativePositionToResource.AccessChild('resource_first_row').AccessChild('resource_content').CountVisibleChildren"
}

macro = {
	description = "num of resource row"
	definition = "ResourceRowCount(RelativePositionToResource)"
	replace_with = "CeilDivide_int32(ResourceTypeCount(RelativePositionToResource), ResourceTypeMaxPerRow)"
}

macro = {
	description = "num of resource per row"
	definition = "ResourceTypePerRow(RelativePositionToResource)"
	replace_with = "CeilDivide_int32(ResourceTypeCount(RelativePositionToResource), ResourceRowCount(RelativePositionToResource))"
}

macro = {
	description = "is last row but not least row?"
	definition = "ResourceRowIsLast(RelativePositionToResource, RowIndex)" # from 0
	replace_with = "EqualTo_int32(ResourceRowCount(RelativePositionToResource), Add_int32(RowIndex, '(int32)1'))"
}
macro = {
	description = "is last row but not least row?"
	definition = "ResourceRowIsIncomplete(RelativePositionToResource, RowIndex)" # from 0
	replace_with = "And(ResourceRowIsLast(RelativePositionToResource, RowIndex), Not(EqualTo_int32(RowIndex, '(int32)0')))"
}

macro = {
	description = "num of resource this row"
	definition = "ResourceTypeThisRow(RelativePositionToResource, RowIndex)" # from 0
	replace_with = "Select_int32( ResourceRowIsIncomplete(RelativePositionToResource, RowIndex), Add_int32('(int32)1', Modulo_int32(Subtract_int32(ResourceTypeCount(RelativePositionToResource), '(int32)1'), ResourceTypePerRow(RelativePositionToResource))), ResourceTypePerRow(RelativePositionToResource) )"
}

macro = {
	description = "space of resource row"
	definition = "ResourceRowSpace(RelativePositionToResource, RowIndex)"  # (Width/(MaxWidth-WidthPerItem*CountThisRow))/(MaxPerCount-CountThisRow+1)
	replace_with = "Divide_int32( Subtract_int32( ResourceRowWidth, Multiply_int32( ResourceTypeWidth, ResourceTypeThisRow(RelativePositionToResource, RowIndex) ) ), Add_int32(ResourceTypeThisRow(RelativePositionToResource, RowIndex),'(int32)1'))"
}
macro = {
	description = "margin of resource row"
	definition = "ResourceRowMargin(RelativePositionToResource, RowIndex)"
	# full line: RowIndex*ResourceRowWidth
	# incomplete line: ResourceTypePerRow*RowIndex*(ResourceTypeWidth+ResourceRowSpace)
	replace_with = "Multiply_int32('(int32)-1', Subtract_int32(Multiply_int32(ResourceTypePerRow(RelativePositionToResource), Multiply_int32(RowIndex, Add_int32(ResourceTypeWidth, ResourceRowSpace(RelativePositionToResource, RowIndex)))), ResourceRowSpace(RelativePositionToResource, RowIndex)))"
}
macro = {
	description = "placeholder of resource row"
	definition = "ResourceRowPlaceholder(RelativePositionToResource, RowIndex)"  # (Width/(MaxWidth-WidthPerItem*CountThisRow))/(MaxPerCount-CountThisRow+1)
	replace_with = "Multiply_int32(Divide_int32(ResourceTypeWidth, '(int32)2'), Subtract_int32(ResourceTypeMaxPerRow, ResourceTypeThisRow(RelativePositionToResource, RowIndex)))"
}


macro = {
	description = "width of resource row"
	definition = "ResourceRowWidth"
	replace_with = "'(int32)220'"
}
macro = {
	description = "width of resource row"
	definition = "ResourceTypeWidth"
	replace_with = "'(int32)44'"
}
macro = {
	description = "width of resource row"
	definition = "ResourceTypeMaxPerRow"
	replace_with = "'(int32)5'"
}
