Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GlitterWorld Prime Mod
Release build
Commits
c7831182
Commit
c7831182
authored
Nov 12, 2018
by
Adam Leyshon
Browse files
Added Ban checks
Corrected typos in translation file Added check for very small silver amounts
parent
36f1d67e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
44 deletions
+85
-44
Glitterworld Prime.sln
Glitterworld Prime.sln
+2
-0
Glitterworld Prime/DialogPrimeCheckSubscription.cs
Glitterworld Prime/DialogPrimeCheckSubscription.cs
+19
-6
Glitterworld Prime/DialogPrimeTrade.cs
Glitterworld Prime/DialogPrimeTrade.cs
+10
-2
Glitterworld Prime/GlitterWorldApi.cs
Glitterworld Prime/GlitterWorldApi.cs
+6
-2
Glitterworld Prime/GlitterWorldItem.cs
Glitterworld Prime/GlitterWorldItem.cs
+11
-13
Glitterworld Prime/Glitterworld Prime.csproj
Glitterworld Prime/Glitterworld Prime.csproj
+1
-0
Glitterworld Prime/Tools/DumpThingData.cs
Glitterworld Prime/Tools/DumpThingData.cs
+31
-18
Languages/English/Keyed/Messages.xml
Languages/English/Keyed/Messages.xml
+5
-3
No files found.
Glitterworld Prime.sln
View file @
c7831182
...
...
@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Glitterworld Prime", "Glitterworld Prime\Glitterworld Prime.csproj", "{1976D016-8918-48C9-A54E-4D9EF7F200B7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6D3468B4-EA3F-4886-BF33-142B8436A96F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
Glitterworld Prime/DialogPrimeCheckSubscription.cs
View file @
c7831182
...
...
@@ -30,6 +30,7 @@ namespace Glitterworld_Prime
private
DownloadStatus
_isDownloadComplete
=
DownloadStatus
.
Incomplete
;
private
bool
_resubscribePromptShown
;
private
GlitterWorldSubscriptionMetadata
_subscriptionMeta
;
private
int
?
_reason
;
#
endregion
...
...
@@ -124,7 +125,17 @@ namespace Glitterworld_Prime
break
;
case
DownloadStatus
.
Failed
:
Messages
.
Message
(
"GWPUnavailable"
.
Translate
(),
MessageTypeDefOf
.
NegativeEvent
);
string
message
;
if
(
_reason
!=
null
)
{
message
=
_reason
==
403
?
"GWPBanned"
.
Translate
()
:
"GWPUnavailable"
.
Translate
();
}
else
{
message
=
"GWPUnavailable"
.
Translate
();
}
Messages
.
Message
(
message
,
MessageTypeDefOf
.
NegativeEvent
);
Close
();
break
;
}
...
...
@@ -180,9 +191,11 @@ namespace Glitterworld_Prime
}
// Update Colony MetaData
if
(!
GlitterWorldApi
.
SendColonyMeta
(
_player
.
Map
))
int
reason
;
if
(!
GlitterWorldApi
.
SendColonyMeta
(
_player
.
Map
,
out
reason
))
{
_isDownloadComplete
=
DownloadStatus
.
Failed
;
if
(
reason
!=
0
)
_reason
=
reason
;
return
;
}
...
...
@@ -196,7 +209,7 @@ namespace Glitterworld_Prime
}
LogWriter
.
WriteMessage
(
$"GlitterWorld API: Subscripton server has expiry tick @
{
_subscriptionMeta
.
TickSubscriptionExpires
}
"
);
$"GlitterWorld API: Subscript
i
on server has expiry tick @
{
_subscriptionMeta
.
TickSubscriptionExpires
}
"
);
_mapComponent
.
SubscriptionExpiry
=
_subscriptionMeta
.
TickSubscriptionExpires
;
_isDownloadComplete
=
DownloadStatus
.
Complete
;
...
...
@@ -215,10 +228,10 @@ namespace Glitterworld_Prime
private
Dialog_MessageBox
CannotAffordSub
()
{
var
s
=
new
StringBuilder
();
s
.
AppendLine
(
"GWPDial
g
oCantAffordSubscription1"
.
Translate
());
s
.
AppendLine
(
"GWPDial
g
oCantAffordSubscription2"
.
Translate
());
s
.
AppendLine
(
"GWPDialo
g
CantAffordSubscription1"
.
Translate
());
s
.
AppendLine
(
"GWPDialo
g
CantAffordSubscription2"
.
Translate
());
s
.
AppendLine
(
$"
{
_subscriptionMeta
.
SubscriptionCost
}
{
"GWPCurrency"
.
Translate
()}
"
);
return
new
Dialog_MessageBox
(
s
.
ToString
(),
title
:
"GWPDial
g
oCantAffordSubscriptionTitle"
.
Translate
());
return
new
Dialog_MessageBox
(
s
.
ToString
(),
title
:
"GWPDialo
g
CantAffordSubscriptionTitle"
.
Translate
());
}
#
endregion
...
...
Glitterworld Prime/DialogPrimeTrade.cs
View file @
c7831182
...
...
@@ -164,7 +164,7 @@ namespace Glitterworld_Prime
{
Action
action
=
()
=>
{
Log
.
Message
(
"
Button clicke
d"
,
true
);
Log
.
Message
(
"
GWP Starting order buil
d"
,
true
);
bool
flag
;
...
...
@@ -172,7 +172,7 @@ namespace Glitterworld_Prime
if
(!
TradeSession
.
deal
.
TryExecute
(
out
flag
))
{
Log
.
Message
(
"Error
@
TradeSession.deal.TryExecute()"
,
true
);
Log
.
Message
(
"Error
at
TradeSession.deal.TryExecute()
or Colony couldn't afford it
"
,
true
);
return
;
}
...
...
@@ -205,6 +205,14 @@ namespace Glitterworld_Prime
};
if
(
TradeSession
.
deal
.
DoesTraderHaveEnoughSilver
())
{
var
amt
=
TradeSession
.
deal
.
SilverTradeable
.
CountToTransferToSource
;
if
(
amt
>
0
&&
amt
<
1
)
{
SoundDefOf
.
ClickReject
.
PlayOneShotOnCamera
(
null
);
Find
.
WindowStack
.
Add
(
Dialog_MessageBox
.
CreateConfirmation
(
"GWPGiveItAway"
.
Translate
(),
action
,
false
,
null
));
}
action
();
}
else
...
...
Glitterworld Prime/GlitterWorldApi.cs
View file @
c7831182
...
...
@@ -363,10 +363,10 @@ namespace Glitterworld_Prime
}
public
static
bool
SendColonyMeta
(
Map
map
)
public
static
bool
SendColonyMeta
(
Map
map
,
out
int
reason
)
{
LogWriter
.
WriteMessage
(
"Sending Colony Metadata"
);
reason
=
0
;
var
client
=
CreateRestClient
();
// Send colony metadata.
...
...
@@ -407,6 +407,10 @@ namespace Glitterworld_Prime
LogWriter
.
WriteMessage
(
$"Colony ID from server:
{
Utilities
.
GetMapComponent
(
map
).
ColonyId
}
"
);
return
true
;
case
HttpStatusCode
.
Forbidden
:
// Banned!
reason
=
403
;
return
false
;
}
LogWriter
.
WriteErrorMessage
(
"Failed to get trade identifier, Trades will fail."
);
...
...
Glitterworld Prime/GlitterWorldItem.cs
View file @
c7831182
...
...
@@ -8,6 +8,7 @@
#endregion
using
System
;
using
System.Web.Script.Serialization
;
namespace
Glitterworld_Prime
{
...
...
@@ -34,18 +35,8 @@ namespace Glitterworld_Prime
public
string
Quality
{
get
{
if
(
_quality
==
null
)
_quality
=
""
;
return
_quality
;
}
set
{
if
(
value
==
null
)
_quality
=
""
;
else
_quality
=
value
;
}
get
{
return
_quality
??
(
_quality
=
""
);
}
set
{
_quality
=
value
??
""
;
}
}
public
int
Quantity
{
get
;
set
;
}
...
...
@@ -70,6 +61,7 @@ namespace Glitterworld_Prime
public
float
SellPriceOverride
{
get
;
set
;
}
#
endregion
//public GlitterWorldItem(string name, float currentBuyPrice, float baseMarketValue, int quantity,
...
...
@@ -83,4 +75,10 @@ namespace Glitterworld_Prime
// Quality = quality;
//}
}
public
class
GlitterWorldItemDumpData
:
GlitterWorldItem
{
public
string
LocalizedName
{
get
;
set
;
}
public
string
LanguageCode
{
get
;
set
;
}
}
}
Glitterworld Prime/Glitterworld Prime.csproj
View file @
c7831182
...
...
@@ -47,6 +47,7 @@
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Web.Extensions"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
<Reference
Include=
"System.Data"
/>
...
...
Glitterworld Prime/Tools/DumpThingData.cs
View file @
c7831182
...
...
@@ -20,7 +20,7 @@ namespace Glitterworld_Prime.Tools
thing
.
TryGetComp
<
CompQuality
>().
SetQuality
(
quality
,
ArtGenerationContext
.
Outsider
);
}
private
static
IEnumerable
<
GlitterWorldItem
>
ComputeItemsMadeFromStuff
(
ThingDef
thing
,
private
static
IEnumerable
<
GlitterWorldItem
DumpData
>
ComputeItemsMadeFromStuff
(
ThingDef
thing
,
Dictionary
<
StuffCategoryDef
,
List
<
ThingDef
>>
stuffData
)
{
foreach
(
var
category
in
thing
.
stuffCategories
)
...
...
@@ -31,18 +31,19 @@ namespace Glitterworld_Prime.Tools
// Create the Thing
Thing
t
=
Utilities
.
CreateThing
(
thing
.
defName
,
1
,
stuff
.
defName
);
yield
return
new
GlitterWorldItem
()
yield
return
new
GlitterWorldItem
DumpData
()
{
Name
=
thing
.
defName
,
StuffType
=
stuff
.
defName
,
BaseMarketValue
=
t
.
MarketValue
,
MinifiedContainer
=
thing
.
Minifiable
MinifiedContainer
=
thing
.
Minifiable
,
LocalizedName
=
$"
{
stuff
.
LabelCap
}
{
thing
.
LabelCap
}
"
};
}
}
}
private
static
IEnumerable
<
GlitterWorldItem
>
ComputeItemsMadeFromStuffWithQuality
(
ThingDef
thing
,
private
static
IEnumerable
<
GlitterWorldItem
DumpData
>
ComputeItemsMadeFromStuffWithQuality
(
ThingDef
thing
,
Dictionary
<
StuffCategoryDef
,
List
<
ThingDef
>>
stuffData
)
{
for
(
var
quality
=
2
;
quality
<
7
;
quality
++)
...
...
@@ -53,41 +54,45 @@ namespace Glitterworld_Prime.Tools
{
Thing
t
=
Utilities
.
CreateThing
(
thing
.
defName
,
1
,
stuff
.
defName
);
setQuality
(
t
,
(
QualityCategory
)
quality
);
var
qualityObject
=
(
QualityCategory
)
quality
;
setQuality
(
t
,
qualityObject
);
yield
return
new
GlitterWorldItem
()
yield
return
new
GlitterWorldItem
DumpData
()
{
Name
=
thing
.
defName
,
Quality
=
Enum
.
GetName
(
typeof
(
QualityCategory
),
quality
),
StuffType
=
stuff
.
defName
,
BaseMarketValue
=
t
.
MarketValue
,
MinifiedContainer
=
thing
.
Minifiable
MinifiedContainer
=
thing
.
Minifiable
,
LocalizedName
=
$"
{
qualityObject
.
GetLabel
()}
{
stuff
.
LabelCap
}
{
thing
.
LabelCap
}
"
};
}
}
}
private
static
IEnumerable
<
GlitterWorldItem
>
ComputeItemsWithQuality
(
ThingDef
thing
)
private
static
IEnumerable
<
GlitterWorldItem
DumpData
>
ComputeItemsWithQuality
(
ThingDef
thing
)
{
for
(
var
quality
=
2
;
quality
<
7
;
quality
++)
{
Thing
t
=
Utilities
.
CreateThing
(
thing
.
defName
,
1
);
setQuality
(
t
,
(
QualityCategory
)
quality
);
yield
return
new
GlitterWorldItem
()
var
qualityObject
=
(
QualityCategory
)
quality
;
setQuality
(
t
,
qualityObject
);
yield
return
new
GlitterWorldItemDumpData
()
{
Name
=
thing
.
defName
,
Quality
=
Enum
.
GetName
(
typeof
(
QualityCategory
),
quality
),
BaseMarketValue
=
t
.
MarketValue
,
MinifiedContainer
=
thing
.
Minifiable
MinifiedContainer
=
thing
.
Minifiable
,
LocalizedName
=
$"
{
qualityObject
.
GetLabel
()}
{
thing
.
LabelCap
}
"
};
}
}
private
static
IEnumerable
<
GlitterWorldItem
>
ComputeThingDef
(
ThingDef
thing
,
private
static
IEnumerable
<
GlitterWorldItem
DumpData
>
ComputeThingDef
(
ThingDef
thing
,
Dictionary
<
StuffCategoryDef
,
List
<
ThingDef
>>
stuffData
)
{
var
result
=
new
List
<
GlitterWorldItem
>();
var
result
=
new
List
<
GlitterWorldItem
DumpData
>();
// Add support for things made of stuff.
if
(
thing
.
MadeFromStuff
)
...
...
@@ -103,21 +108,22 @@ namespace Glitterworld_Prime.Tools
if
(
thing
.
HasComp
(
typeof
(
CompQuality
)))
result
.
AddRange
(
ComputeItemsWithQuality
(
thing
));
else
result
.
Add
(
new
GlitterWorldItem
()
result
.
Add
(
new
GlitterWorldItem
DumpData
()
{
Name
=
thing
.
defName
,
BaseMarketValue
=
thing
.
BaseMarketValue
,
MinifiedContainer
=
thing
.
Minifiable
MinifiedContainer
=
thing
.
Minifiable
,
LocalizedName
=
thing
.
LabelCap
});
}
return
result
;
}
private
static
IEnumerable
<
GlitterWorldItem
>
GetThingData
()
private
static
IEnumerable
<
GlitterWorldItem
DumpData
>
GetThingData
()
{
var
stuffCategories
=
new
Dictionary
<
StuffCategoryDef
,
List
<
ThingDef
>>();
var
thingData
=
new
List
<
GlitterWorldItem
>();
var
thingData
=
new
List
<
GlitterWorldItem
DumpData
>();
var
stuffCategoryDefs
=
DefDatabase
<
StuffCategoryDef
>.
AllDefsListForReading
;
var
things
=
DefDatabase
<
ThingDef
>.
AllDefsListForReading
;
...
...
@@ -154,7 +160,14 @@ namespace Glitterworld_Prime.Tools
internal
static
void
DumpData
()
{
var
data
=
new
List
<
GlitterWorldItem
>(
GetThingData
());
var
languageName
=
Verse
.
LanguageDatabase
.
activeLanguage
.
FriendlyNameEnglish
;
var
data
=
new
List
<
GlitterWorldItemDumpData
>(
GetThingData
());
data
.
ForEach
(
t
=>
{
t
.
LanguageCode
=
languageName
.
ToLowerInvariant
();
t
.
LocalizedName
=
t
.
LocalizedName
.
ToLowerInvariant
();
});
var
path
=
Path
.
Combine
(
GenFilePaths
.
SaveDataFolderPath
,
"GWP-MarketDataDump.json"
);
var
jsonString
=
RestSharp
.
SimpleJson
.
SerializeObject
(
data
);
File
.
WriteAllText
(
path
,
jsonString
);
...
...
Languages/English/Keyed/Messages.xml
View file @
c7831182
...
...
@@ -15,8 +15,10 @@
<GWPDialogSubscribe1>
Resubscribe? This will cost
</GWPDialogSubscribe1>
<GWPDialogSubscribe2>
for
</GWPDialogSubscribe2>
<GWPSubscriptionDuration>
1 Quadrum
</GWPSubscriptionDuration>
<GWPDial
g
oCantAffordSubscriptionTitle>
Not enough resources
</GWPDial
g
oCantAffordSubscriptionTitle>
<GWPDial
g
oCantAffordSubscription1>
Your GlitterWorld Prime Subscription has ended
</GWPDial
g
oCantAffordSubscription1>
<GWPDial
g
oCantAffordSubscription2>
But you cannot afford to renew, The cost is:
</GWPDial
g
oCantAffordSubscription2>
<GWPDialo
g
CantAffordSubscriptionTitle>
Not enough resources
</GWPDialo
g
CantAffordSubscriptionTitle>
<GWPDialo
g
CantAffordSubscription1>
Your GlitterWorld Prime Subscription has ended
</GWPDialo
g
CantAffordSubscription1>
<GWPDialo
g
CantAffordSubscription2>
But you cannot afford to renew, The cost is:
</GWPDialo
g
CantAffordSubscription2>
<GWPCurrency>
Silver
</GWPCurrency>
<GWPGiveItAway>
We can't pay you for goods worth less than 1 Silver, Continue anyway?
</GWPGiveItAway>
<GWPBanned>
You have been banned from using GlitterWorld Prime
</GWPBanned>
</LanguageData>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment