Revision 1f6d1786
Added by Leszek Koltunski over 2 years ago
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanActivity.java | ||
---|---|---|
28 | 28 |
import android.view.View; |
29 | 29 |
import android.view.ViewGroup; |
30 | 30 |
import android.view.WindowManager; |
31 |
import android.widget.AdapterView; |
|
31 | 32 |
import android.widget.LinearLayout; |
33 |
import android.widget.SimpleAdapter; |
|
32 | 34 |
import android.widget.TextView; |
33 | 35 |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.HashMap; |
|
38 |
import java.util.List; |
|
39 |
import java.util.Map; |
|
40 |
|
|
34 | 41 |
import helpers.TransparentImageButton; |
35 | 42 |
|
36 | 43 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 44 |
|
38 | 45 |
public class SokobanActivity extends ListActivity |
39 | 46 |
{ |
40 |
private static final String ITEM_IMAGE = "item_image"; |
|
41 |
private static final String ITEM_TITLE = "item_title"; |
|
42 |
private static final String ITEM_SUBTITLE = "item_subtitle"; |
|
47 |
private static final String L_NUMBER = "lNumber"; |
|
48 |
private static final String L_RECORD = "lRecord"; |
|
49 |
private static final String L_IMAGE = "lImage"; |
|
50 |
private static final String R_NUMBER = "rNumber"; |
|
51 |
private static final String R_RECORD = "rRecord"; |
|
52 |
private static final String R_IMAGE = "rImage"; |
|
43 | 53 |
|
44 | 54 |
private static final float RATIO_BAR = 0.10f; |
45 | 55 |
private static final float RATIO_INSET = 0.09f; |
... | ... | |
78 | 88 |
|
79 | 89 |
LinearLayout upper = findViewById(R.id.upper_layout); |
80 | 90 |
createUpperLayout(upper); |
81 |
|
|
82 |
/* |
|
83 |
final List<Map<String, Object>> data = new ArrayList<>(); |
|
84 |
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>(); |
|
85 |
|
|
86 |
int index=0; |
|
87 |
|
|
88 |
for( Application app : Application.values() ) |
|
89 |
{ |
|
90 |
final Map<String, Object> item = new HashMap<>(); |
|
91 |
item.put(ITEM_IMAGE, app.icon); |
|
92 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title)); |
|
93 |
item.put(ITEM_SUBTITLE, getText(app.subtitle)); |
|
94 |
data.add(item); |
|
95 |
activityMapping.put(index++, app.activity); |
|
96 |
} |
|
97 |
|
|
98 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this, |
|
99 |
data, |
|
100 |
R.layout.toc_item, |
|
101 |
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, |
|
102 |
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} ); |
|
103 |
setListAdapter(dataAdapter); |
|
104 |
|
|
105 |
getListView().setOnItemClickListener(new OnItemClickListener() |
|
106 |
{ |
|
107 |
@Override |
|
108 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
109 |
{ |
|
110 |
final Class<? extends Activity> activityToLaunch = activityMapping.get(position); |
|
111 |
|
|
112 |
if (activityToLaunch != null) |
|
113 |
{ |
|
114 |
final Intent launchIntent = new Intent(SokobanActivity.this, activityToLaunch); |
|
115 |
startActivity(launchIntent); |
|
116 |
} |
|
117 |
} |
|
118 |
}); |
|
119 |
|
|
120 |
*/ |
|
121 | 91 |
} |
122 | 92 |
|
123 | 93 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
152 | 122 |
} |
153 | 123 |
} |
154 | 124 |
|
125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
126 |
|
|
127 |
@Override |
|
128 |
public void onResume() |
|
129 |
{ |
|
130 |
super.onResume(); |
|
131 |
createListOfLevels(); |
|
132 |
} |
|
133 |
|
|
134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
135 |
|
|
136 |
@Override |
|
137 |
public void onPause() |
|
138 |
{ |
|
139 |
super.onPause(); |
|
140 |
} |
|
141 |
|
|
155 | 142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
156 | 143 |
|
157 | 144 |
private void createUpperLayout(LinearLayout upper) |
... | ... | |
305 | 292 |
default: return huge; |
306 | 293 |
} |
307 | 294 |
} |
295 |
|
|
296 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
297 |
|
|
298 |
private void createListOfLevels() |
|
299 |
{ |
|
300 |
/* |
|
301 |
final List<Map<String, Object>> data = new ArrayList<>(); |
|
302 |
|
|
303 |
int index=0; |
|
304 |
|
|
305 |
for( Application app : Application.values() ) |
|
306 |
{ |
|
307 |
final Map<String, Object> item = new HashMap<>(); |
|
308 |
item.put(ITEM_IMAGE, app.icon); |
|
309 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title)); |
|
310 |
item.put(ITEM_SUBTITLE, getText(app.subtitle)); |
|
311 |
data.add(item); |
|
312 |
} |
|
313 |
|
|
314 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this, |
|
315 |
data, |
|
316 |
R.layout.toc_item, |
|
317 |
new String[] {L_NUMBER, L_RECORD, L_IMAGE, R_NUMBER, R_RECORD, R_IMAGE}, |
|
318 |
new int[] {R.id.leftNumber , R.id.leftRecord , R.id.leftImage , |
|
319 |
R.id.rightNumber, R.id.rightRecord, R.id.rightImage,} ); |
|
320 |
setListAdapter(dataAdapter); |
|
321 |
|
|
322 |
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() |
|
323 |
{ |
|
324 |
@Override |
|
325 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
326 |
{ |
|
327 |
android.util.Log.e("D","id="+id+" position="+position+" clicked!!"); |
|
328 |
} |
|
329 |
}); |
|
330 |
|
|
331 |
*/ |
|
332 |
} |
|
308 | 333 |
} |
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanDatabase.java | ||
---|---|---|
14 | 14 |
public class SokobanDatabase |
15 | 15 |
{ |
16 | 16 |
private static final String TAG_DB = "SokobanDatabase"; |
17 |
private static final String PREFS_NAME = "sokobanPrefsFile"; |
|
18 |
|
|
17 |
private static final String PREFS_NAME = "sokobanPrefsFile"; |
|
19 | 18 |
public static final int BEGIN_LEVELS = 1000; |
20 | 19 |
public static final int INVALID = 1000000; |
21 | 20 |
|
22 |
private static int numrunnings; |
|
23 |
private static int numplayings; |
|
24 |
private static int hash; |
|
25 |
private static String username; |
|
26 |
private static String veriname; |
|
27 |
private static int uniqueid; |
|
28 |
private static int scrollpos; |
|
29 |
private static boolean finishedBootup = false; |
|
30 |
private static String iso = null; |
|
31 |
|
|
32 |
private static SokobanLevels mLevels; |
|
33 |
private static SokobanDatabase mThis =null; |
|
21 |
private static SokobanDatabase mThis =null; |
|
22 |
|
|
23 |
private int mNumRunnings; |
|
24 |
private int mNumPlayings; |
|
25 |
private String mUsername; |
|
26 |
private String mVeriname; |
|
27 |
private int mUniqueid; |
|
28 |
private int mScrollpos; |
|
29 |
private final boolean mFinishedBootup; |
|
30 |
private String mISO = null; |
|
34 | 31 |
private final WeakReference<Context> mContext; |
35 |
|
|
36 | 32 |
|
37 | 33 |
private static final String[] bl = new String[] |
38 | 34 |
{ |
... | ... | |
633 | 629 |
{ |
634 | 630 |
mContext = new WeakReference<>(co); |
635 | 631 |
|
636 |
mLevels = SokobanLevels.getInstance();
|
|
637 |
numrunnings = 0;
|
|
638 |
numplayings = 0;
|
|
639 |
uniqueid = 0;
|
|
640 |
username ="";
|
|
641 |
veriname ="";
|
|
642 |
scrollpos = 0;
|
|
632 |
SokobanLevels levels = SokobanLevels.getInstance();
|
|
633 |
mNumRunnings = 0;
|
|
634 |
mNumPlayings = 0;
|
|
635 |
mUniqueid = 0;
|
|
636 |
mUsername ="";
|
|
637 |
mVeriname ="";
|
|
638 |
mScrollpos = 0;
|
|
643 | 639 |
|
644 | 640 |
for(int i=0; i<BUILTIN_LEVELS; i++) |
645 | 641 |
{ |
646 | 642 |
int xlen = Integer.parseInt(bl[2*i]); |
647 | 643 |
SokobanLevel sl = new SokobanLevel( null, null, INVALID, INVALID, null, false,xlen, bl[2*i+1]); |
648 |
mLevels.addLevel(sl,i);
|
|
644 |
levels.addLevel(sl,i);
|
|
649 | 645 |
} |
650 | 646 |
|
651 |
hash = computeHash(); |
|
652 |
|
|
653 | 647 |
try |
654 | 648 |
{ |
655 | 649 |
SharedPreferences settings = co.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); |
... | ... | |
660 | 654 |
Log.e( TAG_DB, "Failed to retrieve preferences: "+ex.toString()); |
661 | 655 |
} |
662 | 656 |
|
663 |
if( veriname==null ) veriname=""; |
|
664 |
if( username==null ) username=""; |
|
665 |
if( uniqueid==0 ) uniqueid = getDeviceID(); |
|
666 |
|
|
667 |
mLevels.setScroll(scrollpos); |
|
668 |
mLevels.updateMyRecords(username); |
|
657 |
if( mVeriname==null ) mVeriname=""; |
|
658 |
if( mUsername==null ) mUsername=""; |
|
659 |
if( mUniqueid==0 ) mUniqueid = getDeviceID(); |
|
669 | 660 |
|
670 |
if( numrunnings==0 ) SokobanCanvas.setState(SokobanCanvas.STATE_HELP); |
|
661 |
levels.setScroll(mScrollpos); |
|
662 |
levels.updateMyRecords(mUsername); |
|
671 | 663 |
|
672 |
if( hash != computeHash() ) // someone has been messing with RMS ! |
|
673 |
{ |
|
674 |
Log.e(TAG_DB, "messing in DB"); |
|
675 |
|
|
676 |
SokobanLevel sl; |
|
677 |
veriname = ""; |
|
678 |
|
|
679 |
for(int i=0; ; i++) |
|
680 |
{ |
|
681 |
sl = SokobanLevels.getLevel(i); |
|
682 |
if( sl==null ) break; |
|
683 |
sl.resetPrivate(); |
|
684 |
} |
|
685 |
} |
|
686 |
|
|
687 |
finishedBootup = true; |
|
664 |
mFinishedBootup = true; |
|
688 | 665 |
SokobanCanvas.setRepaint(); |
689 | 666 |
} |
690 | 667 |
|
... | ... | |
705 | 682 |
|
706 | 683 |
try |
707 | 684 |
{ |
708 |
num = Integer.valueOf(key).intValue();
|
|
685 |
num = Integer.parseInt(key);
|
|
709 | 686 |
sett= String.valueOf(val); |
710 | 687 |
|
711 | 688 |
switch(num) |
712 | 689 |
{ |
713 |
case 1 : username = sett; break; |
|
714 |
case 2 : veriname = sett; break; |
|
715 |
case 3 : hash = Integer.valueOf(sett).intValue(); break; |
|
716 |
case 4 : numrunnings = Integer.valueOf(sett).intValue(); break; |
|
717 |
case 5 : numplayings = Integer.valueOf(sett).intValue(); break; |
|
718 |
case 6 : uniqueid = Integer.valueOf(sett).intValue(); break; |
|
719 |
case 7 : scrollpos = Integer.valueOf(sett).intValue(); break; |
|
720 |
default: recoverLevel(num,sett); break; |
|
690 |
case 1 : mUsername = sett; break; |
|
691 |
case 2 : mVeriname = sett; break; |
|
692 |
case 3 : mNumRunnings = Integer.parseInt(sett); break; |
|
693 |
case 4 : mNumPlayings = Integer.parseInt(sett); break; |
|
694 |
case 5 : mUniqueid = Integer.parseInt(sett); break; |
|
695 |
case 6 : mScrollpos = Integer.parseInt(sett); break; |
|
721 | 696 |
} |
722 | 697 |
} |
723 | 698 |
catch( Exception ex ) |
724 | 699 |
{ |
725 |
Log.e(TAG_DB, "error retrieving preference "+String.valueOf(val)+" :"+ex.toString());
|
|
700 |
Log.e(TAG_DB, "error retrieving preference "+val+" :"+ex.toString());
|
|
726 | 701 |
} |
727 | 702 |
} |
728 | 703 |
} |
729 | 704 |
} |
730 | 705 |
|
731 |
/////////////////////////////////////////////////////////////////// |
|
732 |
|
|
733 |
private void recoverLevel(int id, String value) |
|
734 |
{ |
|
735 |
int begin=0,end=0,lvlNum; |
|
736 |
String tmp; |
|
737 |
|
|
738 |
//Log.d(TAG_DB, "recovering level "+id+" :"+value); |
|
739 |
|
|
740 |
end = value.indexOf(" ", begin+1); |
|
741 |
|
|
742 |
if( end<0 ) |
|
743 |
{ |
|
744 |
Log.e(TAG_DB, "error recovering level! value: "+value); |
|
745 |
return; |
|
746 |
} |
|
747 |
|
|
748 |
tmp = value.substring(begin,end); |
|
749 |
lvlNum = Integer.valueOf(tmp).intValue(); |
|
750 |
|
|
751 |
recoverLevelData(id,lvlNum,end,value); |
|
752 |
} |
|
753 |
|
|
754 |
/////////////////////////////////////////////////////////////////// |
|
755 |
|
|
756 |
private void recoverLevelData(int id, int num, int begin, String value) |
|
757 |
{ |
|
758 |
int end; |
|
759 |
String tmp; |
|
760 |
SokobanLevel sl; |
|
761 |
int intrinsic = INVALID; |
|
762 |
int mytime = INVALID; |
|
763 |
int mymoves = INVALID; |
|
764 |
int worldtime = INVALID; |
|
765 |
int worldmoves = INVALID; |
|
766 |
String worldname = ""; |
|
767 |
String worldcountry= ""; |
|
768 |
boolean submitted = false; |
|
769 |
|
|
770 |
// recover intrinsic num |
|
771 |
end = value.indexOf(" ", begin+1); |
|
772 |
|
|
773 |
if( end<0 ) |
|
774 |
{ |
|
775 |
Log.e(TAG_DB, "1 error recovering builtin level, value: "+value); |
|
776 |
return; |
|
777 |
} |
|
778 |
|
|
779 |
try |
|
780 |
{ |
|
781 |
tmp = value.substring( begin+1,end); |
|
782 |
intrinsic = Integer.valueOf(tmp).intValue(); |
|
783 |
} |
|
784 |
catch(Exception ex1 ) {Log.e(TAG_DB, "1: "+ex1.toString()); } |
|
785 |
|
|
786 |
begin = end; |
|
787 |
|
|
788 |
// recover mytime |
|
789 |
end = value.indexOf(" ", begin+1); |
|
790 |
|
|
791 |
if( end<0 ) |
|
792 |
{ |
|
793 |
Log.e(TAG_DB, "1 error recovering builtin level, value: "+value); |
|
794 |
return; |
|
795 |
} |
|
796 |
|
|
797 |
try |
|
798 |
{ |
|
799 |
tmp = value.substring( begin+1,end); |
|
800 |
mytime = Integer.valueOf(tmp).intValue(); |
|
801 |
} |
|
802 |
catch(Exception ex1 ) {Log.e(TAG_DB, "1: "+ex1.toString()); } |
|
803 |
|
|
804 |
begin = end; |
|
805 |
|
|
806 |
// recover mymoves |
|
807 |
end = value.indexOf(" ", begin+1); |
|
808 |
|
|
809 |
if( end<0 ) |
|
810 |
{ |
|
811 |
Log.e(TAG_DB, "2 error recovering builtin level, value: "+value); |
|
812 |
return; |
|
813 |
} |
|
814 |
|
|
815 |
try |
|
816 |
{ |
|
817 |
tmp = value.substring( begin+1,end); |
|
818 |
mymoves = Integer.valueOf(tmp).intValue(); |
|
819 |
} |
|
820 |
catch(Exception ex1 ) {Log.e(TAG_DB, "2: "+ex1.toString()); } |
|
821 |
|
|
822 |
begin = end; |
|
823 |
|
|
824 |
// recover worldtime |
|
825 |
end = value.indexOf(" ", begin+1); |
|
826 |
|
|
827 |
if( end<0 ) |
|
828 |
{ |
|
829 |
Log.e(TAG_DB, "3 error recovering builtin level, value: "+value); |
|
830 |
return; |
|
831 |
} |
|
832 |
|
|
833 |
try |
|
834 |
{ |
|
835 |
tmp = value.substring( begin+1,end); |
|
836 |
worldtime = Integer.valueOf(tmp).intValue(); |
|
837 |
} |
|
838 |
catch(Exception ex1 ) {Log.e(TAG_DB, "3: "+ex1.toString()); } |
|
839 |
|
|
840 |
begin = end; |
|
841 |
|
|
842 |
// recover worldmoves |
|
843 |
end = value.indexOf(" ", begin+1); |
|
844 |
|
|
845 |
if( end<0 ) |
|
846 |
{ |
|
847 |
Log.e(TAG_DB, "4 error recovering builtin level, value: "+value); |
|
848 |
return; |
|
849 |
} |
|
850 |
|
|
851 |
try |
|
852 |
{ |
|
853 |
tmp = value.substring( begin+1,end); |
|
854 |
worldmoves = Integer.valueOf(tmp).intValue(); |
|
855 |
} |
|
856 |
catch(Exception ex1 ) {Log.e(TAG_DB, "4: "+ex1.toString()); } |
|
857 |
|
|
858 |
begin = end; |
|
859 |
|
|
860 |
// recover worldname |
|
861 |
end = value.indexOf(" ", begin+1); |
|
862 |
|
|
863 |
if( end<0 ) |
|
864 |
{ |
|
865 |
Log.e(TAG_DB, "5 error recovering builtin level, value: "+value); |
|
866 |
return; |
|
867 |
} |
|
868 |
|
|
869 |
try |
|
870 |
{ |
|
871 |
worldname = value.substring( begin+1,end); |
|
872 |
} |
|
873 |
catch(Exception ex1 ) {Log.e(TAG_DB, "5: "+ex1.toString()); } |
|
874 |
|
|
875 |
begin = end; |
|
876 |
|
|
877 |
// recover worldcountry |
|
878 |
end = value.indexOf(" ", begin+1); |
|
879 |
|
|
880 |
if( end<0 ) |
|
881 |
{ |
|
882 |
Log.e(TAG_DB, "6 error recovering builtin level, value: "+value); |
|
883 |
return; |
|
884 |
} |
|
885 |
|
|
886 |
try |
|
887 |
{ |
|
888 |
worldcountry = value.substring( begin+1,end); |
|
889 |
} |
|
890 |
catch(Exception ex1 ) {Log.e(TAG_DB,"6: "+ex1.toString()); } |
|
891 |
|
|
892 |
begin = end; |
|
893 |
|
|
894 |
// recover submitted |
|
895 |
end = value.indexOf(" ", begin+1); |
|
896 |
|
|
897 |
if( end<0 ) |
|
898 |
{ |
|
899 |
Log.e(TAG_DB, "7 error recovering builtin level, value: "+value); |
|
900 |
return; |
|
901 |
} |
|
902 |
|
|
903 |
try |
|
904 |
{ |
|
905 |
tmp = value.substring( begin+1,end); |
|
906 |
submitted = (Integer.valueOf(tmp).intValue()==1 ? true:false); |
|
907 |
} |
|
908 |
catch(Exception ex1 ) {Log.e(TAG_DB, "7: "+ex1.toString()); } |
|
909 |
|
|
910 |
begin = end; |
|
911 |
|
|
912 |
if( num<BUILTIN_LEVELS ) |
|
913 |
{ |
|
914 |
sl = SokobanLevels.getLevel(num); |
|
915 |
|
|
916 |
if( sl==null ) { Log.e(TAG_DB, "Error recovering builtin level "+num); return; } |
|
917 |
|
|
918 |
// Log.d(TAG_DB, "setting my info: "+mymoves+" "+mytime+" "+username+" "+getCountry() ); |
|
919 |
|
|
920 |
sl.setMyInfo(mymoves,mytime, username, getCountry() ); |
|
921 |
sl.addRecordInfo(worldmoves,worldtime,0,worldname,worldcountry); |
|
922 |
sl.setSubmitted(submitted); |
|
923 |
sl.setRecordId(id); |
|
924 |
} |
|
925 |
else |
|
926 |
{ |
|
927 |
String author="", coun="", position=""; |
|
928 |
int cols=0; |
|
929 |
|
|
930 |
// recover author |
|
931 |
end = value.indexOf(" ", begin+1); |
|
932 |
|
|
933 |
if( end<0 ) |
|
934 |
{ |
|
935 |
Log.e(TAG_DB, "8 error recovering builtin level, value: "+value); |
|
936 |
return; |
|
937 |
} |
|
938 |
|
|
939 |
try |
|
940 |
{ |
|
941 |
author = value.substring( begin+1,end); |
|
942 |
} |
|
943 |
catch(Exception ex1 ) {Log.e(TAG_DB, "8: "+ex1.toString()); } |
|
944 |
|
|
945 |
begin = end; |
|
946 |
|
|
947 |
// recover country |
|
948 |
end = value.indexOf(" ", begin+1); |
|
949 |
|
|
950 |
if( end<0 ) |
|
951 |
{ |
|
952 |
Log.e(TAG_DB, "9 error recovering builtin level, value: "+value); |
|
953 |
return; |
|
954 |
} |
|
955 |
|
|
956 |
try |
|
957 |
{ |
|
958 |
coun = value.substring( begin+1,end); |
|
959 |
} |
|
960 |
catch(Exception ex1 ) {Log.e(TAG_DB, "9: "+ex1.toString()); } |
|
961 |
|
|
962 |
begin = end; |
|
963 |
|
|
964 |
// recover cols |
|
965 |
end = value.indexOf(" ", begin+1); |
|
966 |
|
|
967 |
if( end<0 ) |
|
968 |
{ |
|
969 |
Log.e(TAG_DB, "10 error recovering builtin level, value: "+value); |
|
970 |
return; |
|
971 |
} |
|
972 |
|
|
973 |
try |
|
974 |
{ |
|
975 |
tmp = value.substring( begin+1,end); |
|
976 |
cols = Integer.valueOf(tmp).intValue(); |
|
977 |
} |
|
978 |
catch(Exception ex1 ) {Log.e(TAG_DB, "10: "+ex1.toString()); } |
|
979 |
|
|
980 |
begin = end; |
|
981 |
|
|
982 |
// recover position |
|
983 |
end = value.indexOf(" ", begin+1); |
|
984 |
|
|
985 |
if( end<0 ) |
|
986 |
{ |
|
987 |
Log.e(TAG_DB, "11 error recovering builtin level, value: "+value); |
|
988 |
return; |
|
989 |
} |
|
990 |
|
|
991 |
try |
|
992 |
{ |
|
993 |
position = value.substring( begin+1,end); |
|
994 |
} |
|
995 |
catch(Exception ex1 ) {Log.e(TAG_DB, "11: "+ex1.toString()); } |
|
996 |
|
|
997 |
begin = end; |
|
998 |
|
|
999 |
// Log.d(TAG_DB, "loading created level: "+author+" "+coun+" "+mymoves+" "+mytime); |
|
1000 |
|
|
1001 |
SokobanRecordInfo sri = new SokobanRecordInfo(worldmoves,worldtime,worldname,worldcountry); |
|
1002 |
sl = new SokobanLevel(author,coun,mymoves,mytime,sri,submitted,cols,position); |
|
1003 |
mLevels.insertLevel(sl,num,intrinsic,id); |
|
1004 |
} |
|
1005 |
} |
|
1006 |
|
|
1007 | 706 |
/////////////////////////////////////////////////////////////////// |
1008 | 707 |
|
1009 | 708 |
private int getDeviceID() |
... | ... | |
1029 | 728 |
|
1030 | 729 |
public boolean saveValues() |
1031 | 730 |
{ |
1032 |
//Log.e(TAG_DB, "saveValues: "+finishedBootup); |
|
1033 |
|
|
1034 |
if( !finishedBootup ) return false; |
|
731 |
if( !mFinishedBootup ) return false; |
|
1035 | 732 |
|
1036 | 733 |
boolean ret = false; |
1037 | 734 |
|
1038 |
numrunnings++; |
|
1039 |
hash = computeHash(); |
|
1040 |
scrollpos = SokobanLevels.getScroll(); |
|
735 |
mNumRunnings++; |
|
736 |
mScrollpos = SokobanLevels.getScroll(); |
|
1041 | 737 |
|
1042 | 738 |
try |
1043 | 739 |
{ |
1044 |
Context co = mContext.get();
|
|
1045 |
SharedPreferences settings = co.getSharedPreferences(PREFS_NAME,Context.MODE_PRIVATE);
|
|
1046 |
SharedPreferences.Editor editor = settings.edit();
|
|
740 |
Context co = mContext.get(); |
|
741 |
SharedPreferences settings = co.getSharedPreferences(PREFS_NAME,Context.MODE_PRIVATE); |
|
742 |
SharedPreferences.Editor editor = settings.edit(); |
|
1047 | 743 |
|
1048 |
editor.putString("1", username); |
|
1049 |
editor.putString("2", veriname); |
|
1050 |
editor.putInt("3", hash); |
|
1051 |
editor.putInt("4", numrunnings); |
|
1052 |
editor.putInt("5", numplayings); |
|
1053 |
editor.putInt("6", uniqueid); |
|
1054 |
editor.putInt("7", scrollpos); |
|
1055 |
|
|
1056 |
// Log.d(TAG_DB, "saving: username="+username+" veriname="+veriname+" hash="+hash+" numrunnings="+numrunnings+" numplayings="+numplayings+" uniqueid="+uniqueid+" scrollpos="+scrollpos); |
|
1057 |
|
|
1058 |
if( saveLevels(editor)==false ) return false; |
|
744 |
editor.putString("1", mUsername); |
|
745 |
editor.putString("2", mVeriname); |
|
746 |
editor.putInt("3" , mNumRunnings); |
|
747 |
editor.putInt("4" , mNumPlayings); |
|
748 |
editor.putInt("5" , mUniqueid); |
|
749 |
editor.putInt("6" , mScrollpos); |
|
1059 | 750 |
|
1060 | 751 |
editor.commit(); |
1061 | 752 |
ret = true; |
... | ... | |
1067 | 758 |
|
1068 | 759 |
return ret; |
1069 | 760 |
} |
1070 |
|
|
1071 |
/////////////////////////////////////////////////////////////////// |
|
1072 |
|
|
1073 |
private static boolean saveLevels(SharedPreferences.Editor editor) |
|
1074 |
{ |
|
1075 |
String tmp; |
|
1076 |
int sb; |
|
1077 |
SokobanLevel level; |
|
1078 |
SokobanRecordInfo wr; |
|
1079 |
|
|
1080 |
for(int i=0; ; i++) |
|
1081 |
{ |
|
1082 |
level = SokobanLevels.getLevel(i); |
|
1083 |
if( level==null ) break; |
|
1084 | 761 |
|
1085 |
if( level.isDirty() ) |
|
1086 |
{ |
|
1087 |
wr = level.getRecordInfo(0); |
|
1088 |
sb = level.isSubmitted()==true?1:0; |
|
1089 |
|
|
1090 |
if( wr!=null ) |
|
1091 |
tmp = i+" "+level.getIntrinsicNum()+" "+level.getMyTime()+" "+ |
|
1092 |
level.getMyMoves()+" "+wr.getTime()+" "+wr.getMove()+" "+ |
|
1093 |
wr.getName()+" "+wr.getCountry()+" "+sb+" "; |
|
1094 |
else |
|
1095 |
tmp = i+" "+level.getIntrinsicNum()+" "+level.getMyTime()+" "+ |
|
1096 |
level.getMyMoves()+" "+INVALID+" "+INVALID+" unk unk "+sb+" "; |
|
1097 |
|
|
1098 |
if( i>=BUILTIN_LEVELS ) |
|
1099 |
{ |
|
1100 |
tmp+=level.getAuthor()+" "+level.getCountry()+" "+level.getCols()+" "+level.encodeLevel()+" "; |
|
1101 |
} |
|
1102 |
|
|
1103 |
editor.putString(String.valueOf(level.getRecordId()), tmp); |
|
1104 |
|
|
1105 |
//Log.d(TAG_DB, "saving level "+i+" record id:"+level.getRecordId()+": "+tmp); |
|
1106 |
|
|
1107 |
} |
|
1108 |
} |
|
1109 |
|
|
1110 |
return true; |
|
1111 |
} |
|
1112 |
|
|
1113 | 762 |
/////////////////////////////////////////////////////////////////// |
1114 | 763 |
|
1115 | 764 |
public static void init(Activity act) |
... | ... | |
1119 | 768 |
|
1120 | 769 |
/////////////////////////////////////////////////////////////////// |
1121 | 770 |
|
1122 |
private static int computeHash() |
|
1123 |
{ |
|
1124 |
|
|
1125 |
final int MODULO = 227; |
|
1126 |
int ret = 0; |
|
1127 |
SokobanLevel sl; |
|
1128 |
|
|
1129 |
for(int i=0; ; i++) |
|
1130 |
{ |
|
1131 |
sl = SokobanLevels.getLevel(i); |
|
1132 |
if( sl==null ) break; |
|
1133 |
|
|
1134 |
ret += sl.getMyMoves(); |
|
1135 |
ret += 2*sl.getMyTime(); |
|
1136 |
} |
|
1137 |
|
|
1138 |
int length = veriname==null ? 0 : veriname.length(); |
|
1139 |
|
|
1140 |
for(int i=0;i<length;i++) |
|
1141 |
ret += i*veriname.charAt(i); |
|
1142 |
|
|
1143 |
return (ret%=MODULO); |
|
1144 |
} |
|
1145 |
|
|
1146 |
/////////////////////////////////////////////////////////////////// |
|
1147 |
|
|
1148 |
public static int getNumRunnings() |
|
771 |
public int getNumRunnings() |
|
1149 | 772 |
{ |
1150 |
return numrunnings;
|
|
773 |
return mNumRunnings;
|
|
1151 | 774 |
} |
1152 | 775 |
|
1153 | 776 |
/////////////////////////////////////////////////////////////////// |
1154 | 777 |
|
1155 |
public static int getId()
|
|
778 |
public int getId() |
|
1156 | 779 |
{ |
1157 |
return uniqueid;
|
|
780 |
return mUniqueid;
|
|
1158 | 781 |
} |
1159 | 782 |
|
1160 | 783 |
/////////////////////////////////////////////////////////////////// |
1161 | 784 |
|
1162 |
public static int getNumPlayings()
|
|
785 |
public int getNumPlayings() |
|
1163 | 786 |
{ |
1164 |
return numplayings;
|
|
787 |
return mNumPlayings;
|
|
1165 | 788 |
} |
1166 | 789 |
|
1167 | 790 |
/////////////////////////////////////////////////////////////////// |
1168 | 791 |
|
1169 |
public static void incNumPlayings()
|
|
792 |
public void incNumPlayings() |
|
1170 | 793 |
{ |
1171 |
numplayings++;
|
|
794 |
mNumPlayings++;
|
|
1172 | 795 |
} |
1173 | 796 |
|
1174 | 797 |
/////////////////////////////////////////////////////////////////// |
1175 | 798 |
|
1176 |
public static void setName(String newname)
|
|
799 |
public void setName(String newname) |
|
1177 | 800 |
{ |
1178 |
username = newname;
|
|
801 |
mUsername = newname;
|
|
1179 | 802 |
} |
1180 | 803 |
|
1181 | 804 |
/////////////////////////////////////////////////////////////////// |
1182 | 805 |
|
1183 |
public static String getName()
|
|
806 |
public String getName() |
|
1184 | 807 |
{ |
1185 |
return username;
|
|
808 |
return mUsername;
|
|
1186 | 809 |
} |
1187 | 810 |
|
1188 | 811 |
/////////////////////////////////////////////////////////////////// |
1189 | 812 |
|
1190 |
public static void setVeri(String newveri)
|
|
813 |
public void setVeri(String newveri) |
|
1191 | 814 |
{ |
1192 |
veriname = newveri;
|
|
815 |
mVeriname = newveri;
|
|
1193 | 816 |
} |
1194 | 817 |
|
1195 | 818 |
/////////////////////////////////////////////////////////////////// |
1196 | 819 |
|
1197 |
public static String getVeri()
|
|
820 |
public String getVeri() |
|
1198 | 821 |
{ |
1199 |
return veriname;
|
|
822 |
return mVeriname;
|
|
1200 | 823 |
} |
1201 | 824 |
|
1202 | 825 |
/////////////////////////////////////////////////////////////////// |
... | ... | |
1208 | 831 |
|
1209 | 832 |
/////////////////////////////////////////////////////////////////// |
1210 | 833 |
|
1211 |
public static String getCountry() |
|
834 |
public int getNumLevels() |
|
835 |
{ |
|
836 |
return BUILTIN_LEVELS; |
|
837 |
} |
|
838 |
|
|
839 |
/////////////////////////////////////////////////////////////////// |
|
840 |
|
|
841 |
public String getCountry() |
|
1212 | 842 |
{ |
1213 |
if( iso==null ) iso = SokobanCanvas.getIso();
|
|
843 |
if( mISO==null ) mISO = SokobanCanvas.getIso();
|
|
1214 | 844 |
|
1215 | 845 |
char digit1, digit2; |
1216 | 846 |
|
1217 | 847 |
try |
1218 | 848 |
{ |
1219 |
digit1 = iso.charAt(0);
|
|
1220 |
digit2 = iso.charAt(1);
|
|
849 |
digit1 = mISO.charAt(0);
|
|
850 |
digit2 = mISO.charAt(1);
|
|
1221 | 851 |
} |
1222 | 852 |
catch( Exception ex ) |
1223 | 853 |
{ |
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanLevel.java | ||
---|---|---|
70 | 70 |
move = (byte)m; |
71 | 71 |
} |
72 | 72 |
} |
73 |
private static Vector<Move> moves = new Vector<Move>();
|
|
73 |
private static Vector<Move> moves = new Vector<>(); |
|
74 | 74 |
|
75 | 75 |
private SokobanRecordInfo[] recordList; |
76 | 76 |
private SokobanRecordInfo recordMine; |
... | ... | |
109 | 109 |
|
110 | 110 |
author = a; |
111 | 111 |
country= c; |
112 |
|
|
113 |
recordMine = new SokobanRecordInfo(mm,mt,SokobanDatabase.getName(),SokobanDatabase.getCountry()); |
|
112 |
|
|
113 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
114 |
|
|
115 |
if( db!=null ) |
|
116 |
{ |
|
117 |
recordMine = new SokobanRecordInfo(mm,mt,db.getName(),db.getCountry()); |
|
118 |
} |
|
119 |
else |
|
120 |
{ |
|
121 |
recordMine = new SokobanRecordInfo(mm,mt,"",""); |
|
122 |
} |
|
114 | 123 |
|
115 | 124 |
cutAuthor(); |
116 | 125 |
|
117 | 126 |
cImg = (author==null ? null:SokobanLevels.getInstance().getFlag(c)); |
118 |
|
|
127 |
|
|
119 | 128 |
recordList = new SokobanRecordInfo[mMaxRecords]; |
120 | 129 |
for(int i=0; i<mMaxRecords; i++) recordList[i]=null; |
121 | 130 |
|
... | ... | |
145 | 154 |
|
146 | 155 |
validateScratch = new byte[mRows][mCols]; |
147 | 156 |
cells = new byte[mRows][mCols]; |
148 |
|
|
157 |
|
|
149 | 158 |
recordList = new SokobanRecordInfo[mMaxRecords]; |
150 | 159 |
for(int i=0; i<mMaxRecords; i++) recordList[i]=null; |
151 | 160 |
|
... | ... | |
175 | 184 |
private void cutAuthor() |
176 | 185 |
{ |
177 | 186 |
if( author!=null ) |
178 |
{
|
|
179 |
mPaint.setTextSize(SokobanRecordInfo.getFontSize());
|
|
180 |
|
|
187 |
{ |
|
188 |
mPaint.setTextSize(SokobanRecordInfo.getFontSize()); |
|
189 |
|
|
181 | 190 |
float len2 = mPaint.measureText(strAuthor); |
182 | 191 |
float len1 = mPaint.measureText(author); |
183 | 192 |
int len0 = SokobanLevels.levelInfoW-10-28; |
184 |
|
|
193 |
|
|
185 | 194 |
if( len1+len2>len0 ) |
186 | 195 |
{ |
187 | 196 |
int l = author.length(); |
... | ... | |
193 | 202 |
len1 = mPaint.measureText(author); |
194 | 203 |
} |
195 | 204 |
} |
196 |
}
|
|
205 |
} |
|
197 | 206 |
} |
198 | 207 |
|
199 | 208 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
463 | 472 |
{ |
464 | 473 |
recordId = id; |
465 | 474 |
} |
466 |
|
|
475 |
|
|
467 | 476 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
468 |
|
|
477 |
|
|
469 | 478 |
public int getRecordId() |
470 | 479 |
{ |
471 | 480 |
return recordId; |
472 | 481 |
} |
473 |
|
|
482 |
|
|
474 | 483 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
475 | 484 |
|
476 | 485 |
public void setDirty() |
477 | 486 |
{ |
478 | 487 |
mDirty = true; |
479 | 488 |
} |
480 |
|
|
489 |
|
|
481 | 490 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
482 |
|
|
491 |
|
|
483 | 492 |
public boolean isDirty() |
484 | 493 |
{ |
485 | 494 |
return mDirty; |
486 | 495 |
} |
487 |
|
|
496 |
|
|
488 | 497 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
489 |
|
|
498 |
|
|
490 | 499 |
public void resetPrivate() |
491 |
{ |
|
492 |
recordMine.set(SokobanDatabase.INVALID, SokobanDatabase.INVALID, SokobanDatabase.getName(),SokobanDatabase.getCountry()); |
|
493 |
} |
|
500 |
{ |
|
501 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
502 |
recordMine.set(SokobanDatabase.INVALID, SokobanDatabase.INVALID, db.getName(), db.getCountry()); |
|
503 |
} |
|
494 | 504 |
|
495 | 505 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
496 | 506 |
|
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanLevels.java | ||
---|---|---|
917 | 917 |
{ |
918 | 918 |
if( state==SokobanCanvas.STATE_MAIN && clickedLevel>=0 && dx*dx+dy*dy<=MIN_CLICK_DIST*MIN_CLICK_DIST) |
919 | 919 |
{ |
920 |
SokobanDatabase.incNumPlayings(); |
|
920 |
SokobanDatabase.getInstance().incNumPlayings();
|
|
921 | 921 |
currLevel = clickedLevel; |
922 | 922 |
currMoves = 0; |
923 | 923 |
SokobanCanvas.getMenu().enterPlayState(currLevel); |
... | ... | |
1135 | 1135 |
|
1136 | 1136 |
if( currMoves < m || (currMoves==m && currTime<sl.getMyTime() ) ) |
1137 | 1137 |
{ |
1138 |
sl.setMyInfo(currMoves,currTime,SokobanDatabase.getName(), SokobanDatabase.getCountry()); |
|
1138 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
1139 |
sl.setMyInfo(currMoves,currTime,db.getName(),db.getCountry()); |
|
1139 | 1140 |
sl.setDirty(); |
1140 | 1141 |
SokobanLevelBuffer.invalidateAllR(); |
1141 | 1142 |
SokobanCanvas.setState(SokobanCanvas.STATE_NEWR); |
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanMenu.java | ||
---|---|---|
482 | 482 |
SokobanCanvas.setState(SokobanCanvas.STATE_NAME); |
483 | 483 |
} |
484 | 484 |
break; |
485 |
case SokobanCanvas.STATE_HELP: if( SokobanDatabase.getNumRunnings()==0 ) |
|
485 |
case SokobanCanvas.STATE_HELP: if( SokobanDatabase.getInstance().getNumRunnings()==0 )
|
|
486 | 486 |
SokobanCanvas.setState(SokobanCanvas.STATE_MAIN); |
487 | 487 |
else |
488 | 488 |
SokobanCanvas.setState(SokobanCanvas.STATE_MENU); |
... | ... | |
680 | 680 |
mPaint.setColor(SokobanCanvas.COLOR_BLACK); |
681 | 681 |
mPaint.setTextSize(mFontH); |
682 | 682 |
mPaint.setTextAlign(Align.CENTER); |
683 |
|
|
684 |
c.drawText( "'"+SokobanDatabase.getName()+"'", scrWidth/2, scrHeight/2 - mFontH/2, mPaint); |
|
685 |
c.drawText( strIAT , scrWidth/2, scrHeight/2 + mFontH/2, mPaint); |
|
686 |
c.drawText( strTagain , scrWidth/2, scrHeight/2 + 3*mFontH/2, mPaint); |
|
683 |
|
|
684 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
685 |
|
|
686 |
c.drawText( "'"+db.getName()+"'", scrWidth/2, scrHeight/2 - mFontH/2, mPaint); |
|
687 |
c.drawText( strIAT , scrWidth/2, scrHeight/2 + mFontH/2, mPaint); |
|
688 |
c.drawText( strTagain , scrWidth/2, scrHeight/2 + 3*mFontH/2, mPaint); |
|
687 | 689 |
} |
688 | 690 |
|
689 | 691 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1228 | 1230 |
tkb.setMinSize(1); |
1229 | 1231 |
} |
1230 | 1232 |
|
1231 |
tkb.setText(SokobanDatabase.getName()); |
|
1233 |
|
|
1234 |
|
|
1235 |
tkb.setText(SokobanDatabase.getInstance().getName()); |
|
1232 | 1236 |
mCanvas.getActivity().setContentView(tkb); |
1233 | 1237 |
} |
1234 | 1238 |
|
... | ... | |
1236 | 1240 |
|
1237 | 1241 |
public void okPressed(String text) |
1238 | 1242 |
{ |
1239 |
SokobanDatabase.setName(text); |
|
1243 |
SokobanDatabase.getInstance().setName(text);
|
|
1240 | 1244 |
SokobanLevels.getInstance().updateMyRecords(text); |
1241 | 1245 |
mCanvas.getActivity().setContentView(mCanvas); |
1242 | 1246 |
SokobanCanvas.setRepaint(); |
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanRecordInfo.java | ||
---|---|---|
51 | 51 |
country = c; |
52 | 52 |
movetime = move<SokobanDatabase.INVALID ? move+"m "+time+"s" : null; |
53 | 53 |
img = SokobanLevels.getInstance().getFlag(c); |
54 |
mine = SokobanDatabase.getName().equals(n); |
|
54 |
|
|
55 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
56 |
mine = (db!=null && db.getName().equals(n)); |
|
55 | 57 |
|
56 | 58 |
setCut(); |
57 | 59 |
} |
... | ... | |
71 | 73 |
public void set(String n) |
72 | 74 |
{ |
73 | 75 |
name = n; |
74 |
mine = SokobanDatabase.getName().equals(n); |
|
76 |
mine = SokobanDatabase.getInstance().getName().equals(n);
|
|
75 | 77 |
setCut(); |
76 | 78 |
} |
77 | 79 |
|
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanRecords.java | ||
---|---|---|
111 | 111 |
try |
112 | 112 |
{ |
113 | 113 |
String message=""; |
114 |
int run = SokobanDatabase.getNumRunnings(); |
|
114 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
115 |
int run = db.getNumRunnings(); |
|
115 | 116 |
|
116 | 117 |
if(mode==SUBMITR) |
117 | 118 |
{ |
... | ... | |
125 | 126 |
message+=("&s="+URLencode(getSMSC())); |
126 | 127 |
message+=("&h="+hash); |
127 | 128 |
message+=("&r="+run); |
128 |
message+=("&p="+SokobanDatabase.getNumPlayings());
|
|
129 |
message+=("&i="+SokobanDatabase.getId());
|
|
129 |
message+=("&p="+db.getNumPlayings());
|
|
130 |
message+=("&i="+db.getId());
|
|
130 | 131 |
message+=("&e="+SokobanCanvas.mVersionStr+"a"); |
131 | 132 |
} |
132 | 133 |
else if(mode==DOWNLOADR) |
... | ... | |
243 | 244 |
switch(responseNum) |
244 | 245 |
{ |
245 | 246 |
case 0: SokobanCanvas.setState(SokobanCanvas.STATE_RECO);// success |
246 |
SokobanDatabase.setVeri(name); |
|
247 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
248 |
db.setVeri(name); |
|
247 | 249 |
submitLevelsList(lv); |
248 | 250 |
break; |
249 | 251 |
case -2: SokobanMenu.setAction(SokobanMenu.ACTION_SUBR); |
... | ... | |
413 | 415 |
public void downloadLevels() |
414 | 416 |
{ |
415 | 417 |
mode = DOWNLOADL; |
416 |
name = SokobanDatabase.getName(); |
|
418 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
419 |
name = db.getName(); |
|
417 | 420 |
start(); |
418 | 421 |
} |
419 | 422 |
|
... | ... | |
424 | 427 |
if( mDirtyRecords ) |
425 | 428 |
{ |
426 | 429 |
mode = DOWNLOADR; |
427 |
name = SokobanDatabase.getName(); |
|
428 |
veri = SokobanDatabase.getVeri(); |
|
430 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
431 |
name = db.getName(); |
|
432 |
veri = db.getVeri(); |
|
429 | 433 |
start(); |
430 | 434 |
} |
431 | 435 |
} |
... | ... | |
434 | 438 |
|
435 | 439 |
public boolean submitRecord(int lvl) |
436 | 440 |
{ |
437 |
name = SokobanDatabase.getName(); |
|
441 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
442 |
name = db.getName(); |
|
438 | 443 |
if( name==null || name.length()==0 ) return false; |
439 |
veri = SokobanDatabase.getVeri();
|
|
444 |
veri = db.getVeri();
|
|
440 | 445 |
mode = SUBMITR; |
441 | 446 |
lv = lvl; |
442 | 447 |
|
... | ... | |
448 | 453 |
|
449 | 454 |
public boolean submitLevel(int cols, String level) |
450 | 455 |
{ |
451 |
name = SokobanDatabase.getName(); |
|
456 |
SokobanDatabase db = SokobanDatabase.getInstance(); |
|
457 |
name = db.getName(); |
|
452 | 458 |
if( name==null || name.length()==0 ) return false; |
453 |
veri = SokobanDatabase.getVeri();
|
|
459 |
veri = db.getVeri();
|
|
454 | 460 |
mode = SUBMITL; |
455 | 461 |
mCols = cols; |
456 | 462 |
mLevel= level; |
distorted-sokoban/src/main/res/layout/toc_item.xml | ||
---|---|---|
3 | 3 |
xmlns:android="http://schemas.android.com/apk/res/android" |
4 | 4 |
android:layout_width="match_parent" |
5 | 5 |
android:layout_height="wrap_content" |
6 |
android:baselineAligned="false" |
|
6 | 7 |
android:orientation="horizontal" |
7 | 8 |
android:paddingTop="4dp" |
8 | 9 |
android:paddingBottom="4dp"> |
9 | 10 |
|
10 |
<ImageView |
|
11 |
android:id="@+id/Image" |
|
12 |
android:layout_width="wrap_content" |
|
13 |
android:layout_height="wrap_content" |
|
14 |
android:layout_margin="8dp" |
|
15 |
android:background="@drawable/icon_border"/> |
|
16 |
|
|
17 | 11 |
<LinearLayout |
18 | 12 |
android:layout_width="0dp" |
19 | 13 |
android:layout_height="wrap_content" |
20 | 14 |
android:layout_weight="1" |
21 | 15 |
android:orientation="vertical" |
22 | 16 |
android:layout_gravity="center_vertical"> |
23 |
<TextView |
|
24 |
android:id="@+id/Title" |
|
25 |
android:layout_width="match_parent" |
|
26 |
android:layout_height="wrap_content" |
|
27 |
android:textStyle="bold"/> |
|
28 |
<TextView |
|
29 |
android:id="@+id/SubTitle" |
|
30 |
android:layout_width="wrap_content" |
|
31 |
android:layout_height="wrap_content"/> |
|
17 |
|
|
18 |
<LinearLayout |
|
19 |
android:layout_width="match_parent" |
|
20 |
android:layout_height="wrap_content" |
|
21 |
android:orientation="horizontal" |
|
22 |
android:paddingTop="4dp" |
|
23 |
android:paddingBottom="4dp"> |
|
24 |
|
|
25 |
<TextView |
|
26 |
android:id="@+id/leftNumber" |
|
27 |
android:layout_width="match_parent" |
|
28 |
android:layout_height="wrap_content" |
|
29 |
android:textStyle="bold"/> |
|
30 |
<TextView |
|
31 |
android:id="@+id/leftRecord" |
|
32 |
android:layout_width="wrap_content" |
|
33 |
android:layout_height="wrap_content"/> |
|
34 |
</LinearLayout> |
|
35 |
|
|
36 |
<ImageView |
|
37 |
android:id="@+id/leftImage" |
|
38 |
android:layout_width="wrap_content" |
|
39 |
android:layout_height="wrap_content" |
|
40 |
android:contentDescription="@string/level_image" |
|
41 |
android:layout_margin="8dp" |
|
42 |
android:background="@drawable/icon_border"/> |
|
43 |
</LinearLayout> |
|
44 |
<LinearLayout |
|
45 |
android:layout_width="0dp" |
|
46 |
android:layout_height="wrap_content" |
|
47 |
android:layout_weight="1" |
|
48 |
android:orientation="vertical" |
|
49 |
android:layout_gravity="center_vertical"> |
|
50 |
|
|
51 |
<LinearLayout |
|
52 |
android:layout_width="match_parent" |
|
53 |
android:layout_height="wrap_content" |
|
54 |
android:orientation="horizontal" |
|
55 |
android:paddingTop="4dp" |
|
56 |
android:paddingBottom="4dp"> |
|
57 |
|
|
58 |
<TextView |
|
59 |
android:id="@+id/rightNumber" |
|
60 |
android:layout_width="match_parent" |
|
61 |
android:layout_height="wrap_content" |
|
62 |
android:textStyle="bold"/> |
|
63 |
<TextView |
|
64 |
android:id="@+id/rightRecord" |
|
65 |
android:layout_width="wrap_content" |
|
66 |
android:layout_height="wrap_content"/> |
|
67 |
</LinearLayout> |
|
68 |
|
|
69 |
<ImageView |
|
70 |
android:id="@+id/rightImage" |
|
71 |
android:layout_width="wrap_content" |
|
72 |
android:layout_height="wrap_content" |
|
73 |
android:contentDescription="@string/level_image" |
|
74 |
android:layout_margin="8dp" |
|
75 |
android:background="@drawable/icon_border"/> |
|
32 | 76 |
</LinearLayout> |
33 | 77 |
</LinearLayout> |
distorted-sokoban/src/main/res/values/strings.xml | ||
---|---|---|
66 | 66 |
<string name="nocd">Number of crates does</string> |
67 | 67 |
<string name="netn">not equal the number</string> |
68 | 68 |
<string name="ods">of destination squares</string> |
69 |
|
|
70 |
<string name="level_image">Level Image</string> |
|
69 | 71 |
</resources> |
Also available in: Unified diff
Lots of progress with the main screen