-
Notifications
You must be signed in to change notification settings - Fork 0
/
reskin ios2and.py
executable file
·126 lines (108 loc) · 5.04 KB
/
reskin ios2and.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/local/bin/python3 -u
import argparse, sys, reskinutils, os
print("iOS 2 Android slots reskinner v1.0")
defaultCoins = 5000
# Required arguments
parser = argparse.ArgumentParser(description='Reskin an Android slot machine based on iOS slot machine')
# game name
parser.add_argument('-name', required=True, help='Name of the game to be present on device (should be rathe short and comply with title in ASO)')
# source dir
parser.add_argument('-source', required=True, help='Source dir with iOS game')
# target dir (duplicated dir)
parser.add_argument('-target', required=True, help='Target dir of duplicated version of Android prototype')
# bundle id
parser.add_argument('-bundle', required=True, help='Bundle ID')
# BASE KEY for IAP
parser.add_argument('-basekey', required=True, help='BASE KEY for IAP selling')
# Coins
parser.add_argument('-coins', default = defaultCoins, help='Initial coins amount, default is ' + str(defaultCoins))
# server ID
parser.add_argument('-id', required=True, help='UNIVERSE server ID')
# run or not?
parser.add_argument('-run', help='Wet run. Otherwise, just dry run')
# Arguments
args = parser.parse_args()
name = args.name
srcDir = args.source
trgDir = args.target
bundle = args.bundle
basekey = args.basekey
coins = args.coins
serverID = args.id
reskinutils.run = args.run
# Files
androidManifestFile = trgDir + "/AndroidManifest.xml"
androidManifestBinFile = trgDir + "/bin/AndroidManifest.xml"
stringsFile = trgDir + "/res/values/strings.xml"
serverManagerFile = trgDir + "/src/com/appninja/serveradsmanager/ServerManager.java"
bigCasinoSlotsActivityFile = trgDir + "/src/com/appninja/slots/BigCasinoSlotsActivity.java"
receiverFile = trgDir + "/src/com/appninja/slots/Receiver.java"
mainMenuLayerFile = trgDir + "/src/com/awesomegames/bigcasinoslots/Layers/MainMenuLayer.java"
javaFiles = trgDir + "/src/com/*/*/*.java"
javaFiles2 = trgDir + "/src/com/*/*/*/*.java"
if __name__ == '__main__':
# FILES REPLACEMENT
# -----------------
trgAssets = trgDir + "/assets"
trgRes = trgDir + "/res"
srcReskin = srcDir + "/SimpleSlots/artwork/reskin"
# replace worlds
print("Replacing worlds assets...")
reskinutils.copyFilesByGlob(srcReskin + "/LevelSelect/game*@2x.*", trgAssets)
reskinutils.checkCopy(2*4 + 2)
print("Done.")
# replace reels
print("Replacing reels assets...")
reelsDict = ["gems", "horse", "mega", "slot"]
assetsDict = ["7", "A", "bonus", "diamond", "J", "K", "lemon", "Q", "star", "wild"]
# copy lvl[i]/lvl[i]item_<asset_name>@2x.png to <reels_name>item_<asset_name_title>@2x.png & <reels_name>/<asset_name_title>_<reels_name>.png
for i in range(0, len(reelsDict)):
for j in range(0, len(assetsDict)):
fileToCopy = srcReskin + "/lvl" + str(i+1) + "/lvl" + str(i+1) + "item_" + assetsDict[j] + "@2x.png"
if not (os.path.isfile(fileToCopy)):
print("Cannot find " + fileToCopy + ", trying to capitalizing asset name...")
fileToCopy = srcReskin + "/lvl" + str(i+1) + "/lvl" + str(i+1) + "item_" + assetsDict[j].title() + "@2x.png"
if not (os.path.isfile(fileToCopy)):
sys.exit("Cannot find " + srcReskin + "/lvl" + str(i+1) + "/lvl" + str(i+1) + "item_" + assetsDict[j] + "@2x.png or " + fileToCopy)
reskinutils.copyFilesByName(fileToCopy, trgAssets + "/" + reelsDict[i] + "item_" + assetsDict[j].title() + "@2x.png")
reskinutils.copyFilesByName(fileToCopy, trgAssets + "/" + reelsDict[i] + "/" + assetsDict[j].title() + "_" + reelsDict[i] +".png")
reskinutils.checkCopy(len(reelsDict) * len(assetsDict) * 2)
print("Done.")
# replace icons
print("Replacing icons...")
# 72 x 72, 57 x 57, 144 x 144
sizesDict = ["72x72", "57x57", "72x72@2x"]
iconsDict = ["drawable-hdpi/icon.png", "drawable-mdpi/icon.png", "drawable-xhdpi/icon.png"]
for i in range(0, len(iconsDict)):
reskinutils.copyFilesByGlob(srcDir + "/AppIcon" + sizesDict[i] + ".png", trgRes + "/" + iconsDict[i])
reskinutils.checkCopy(len(iconsDict))
print("Done.")
# CODE REPLACEMENT
# ----------------
# replace game name
print("Replacing game name...")
reskinutils.replaceInFile(stringsFile, "enter_game_name_here", name)
reskinutils.replaceInFile(receiverFile, "enter_game_name_here", name)
print("Done.")
# replace bundleID
print("Replacing bundle ID...")
reskinutils.replaceInFile(androidManifestFile, "enter_bundle_id_here", bundle)
reskinutils.replaceInFile(androidManifestBinFile, "enter_bundle_id_here", bundle)
reskinutils.replaceInFileByGlob(javaFiles, "enter_bundle_id_here", bundle)
reskinutils.replaceInFileByGlob(javaFiles2, "enter_bundle_id_here", bundle)
print("Done.")
# replace server ID
print("Replacing server ID...")
reskinutils.replaceInFile(serverManagerFile, "enter_server_id_here", serverID)
print("Done.")
# replace BASE_KEY for IAP
print("Replacing BASE KEY...")
reskinutils.replaceInFile(bigCasinoSlotsActivityFile, "enter_base_key_here", basekey)
print("Done.")
# replace initial coins
print("Replacing initial coins to " + str(coins) + "...")
reskinutils.replaceInFile(mainMenuLayerFile, "enter_initial_coins_here", str(coins))
print("Done.")
# END OF CODE REPLACEMENT
sys.exit("Done all!")
sys.exit("Nothing to do...")