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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
|
#!/bin/bash
# Copyright (C) 2007-2011 PlayOnLinux Team
# Copyright (C) 2007-2011 Pâris Quentin
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# scripts.lib
# -----------
#
# This lib contains all function to control PlayOnLinux setup windows
export POL_SetupWindow_ID=$$ # Au moins 100000 fois plus logique, et plus simple
POL_SetupWindow_Init ()
{
# Open PlayOnLinux setup window. Should be use only once in a script !
# Needed for POL_SetupWindow_* functions
# Usage: POL_SetupWindow_Init
local arg1
local arg2
local arg3
[ "$1" = "--protect" ] && arg3="protect" && shift
[ "$POL_SetupWindow_TopImage" = "" ] && arg1="$1" || arg1="$POL_SetupWindow_TopImage"
[ "$POL_SetupWindow_LeftImage" = "" ] && arg2="$2" || arg2="$POL_SetupWindow_LeftImage"
[ "$arg1" = "" ] && arg1="None"
[ "$arg2" = "" ] && arg2="None"
[ "$arg3" = "" ] && arg3="None"
mkdir -p "$REPERTOIRE/configurations/guis/"
echo "Wait" > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
cat << EOF > "$REPERTOIRE/configurations/guis/index_$POL_ID"
Open
$POL_SetupWindow_ID
$arg1
$arg2
$arg3
$$
EOF
export SETUPWINDOW_INIT="true"
}
POL_SetupWindow_Close ()
{
# Close PlayOnLinux setup window.
# After this command, POL_SetupWindow_* functions won't work
# Should be used at the end of the script if POL_SetupWindow_Init has been called
# Usage: POL_SetupWindow_Close
if [ "$POL_SCRIPT_FAILED" = "YES" -a -n "$LOGTITLE" -a -n "$DEBUGGING" -a -z "$NOBUGREPORT" ]
then
POL_SetupWindow_question "$(eval_gettext "An error occured during the installation process\n\nDo you want to send the bug to $APPLICATION_TITLE ?")" "$TITLE"
if [ "$APP_ANSWER" = "TRUE" ]
then
export LOGTITLE
bash "$PLAYONLINUX/bash/bug_report" &
fi
fi
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
exit
EOF
export SETUPWINDOW_INIT="false"
}
POL_SetupWindow_presentation ()
{
# Default presentation of a script
# Usage: POL_SetupWindow_presentation [Program's name] [Program's editor] [Editor's url] [Scriptor's name] [Prefix's name]
[ "$3" = "" ] || url="($3)"
POL_SetupWindow_free_presentation "$(eval_gettext 'Welcome to $APPLICATION_TITLE Installation Wizard.')" "$(eval_gettext 'This wizard will help you install ')$1$(eval_gettext ' on your computer.')\n\n$(eval_gettext 'This program was created by: ')$2\n$url\n\n$(eval_gettext 'This installation program is provided by: ')$4\n\n$1$(eval_gettext ' will be installed in: ')$REPERTOIRE/wineprefix/$5$(eval_gettext "\n\n$APPLICATION_TITLE is not responsable for anything that might happen as a result of using these scripts.\n\n")$(eval_gettext 'Click Next to start')"
}
POL_SetupWindow_free_presentation ()
{
# Free presentation for a script
# Usage POL_SetupWindow_free_presentation [title] [message]
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
free_presentation
$1
$2
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
fi
}
POL_SetupWindow_message ()
{
# Shows a simple message
# Usage POL_SetupWindow_message [message] [title]
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
message
$1
$2
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
fi
}
POL_SetupWindow_missing ()
{
# Shows a message if once's program is missing
# Read depend.lib
# Usage POL_SetupWindow_missing
if [ "$MANQUE" = "true" ]
then
LNG_MISSING_ERROR=$(eval_gettext "One or more program(s) are missing. Please install them and run the script again.")
POL_SetupWindow_message "$LNG_MISSING_ERROR\n\n$MISSING" "$(eval_gettext Error)"
POL_SetupWindow_Close
exit $EXIT_MISSING
fi
}
POL_SetupWindow_licence ()
{
# Shows a licence file, and force the user to accept it to continue
# Usage POL_SetupWindow_licence [message] [title] [licence's file]
if [ -f "$3" ]
then
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
licence
$1
$2
$3
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
fi
fi
}
POL_SetupWindow_wait_next_signal ()
{
# Wait for next POL_SetupWindow_ command
# Shows a pulsebar
# Usage POL_SetupWindow_wait_next_signal [message] [title]
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
attendre_signal
$1
$2
$TIMESTAMP
EOF
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
exit
fi
}
POL_SetupWindow_wait_button ()
{
# Wait for next POL_SetupWindow_ command
# Shows a pulsebar
# Usage POL_SetupWindow_wait_next_signal [message] [title] [Button text] [Command] [Confirm message (0 = No confirmation needed)]
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
attendre_signal_b
$1
$2
$3
export PLAYONLINUX="$PLAYONLINUX" ; export WINEPREFIX="$WINEPREFIX" ; export PATH="$PATH" ; export LD_LIBRARY_PATH="$LD_LIBRARY_PATH" ; $4
$5
$TIMESTAMP
EOF
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
exit
fi
}
POL_SetupWindow_pulsebar ()
{
# Same than POL_SetupWindow_wait_next_signal, except that you can control the bar
# Usage POL_SetupWindow_pulsebar [message] [title]
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
pulsebar
$1
$2
$TIMESTAMP
EOF
sleep 0.2 #sleeping 0.2 GUI have to read dialog file. see bug #30
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
exit
fi
}
POL_SetupWindow_pulse ()
{
# Change the pulsebar position (0 - 100)
# Usage POL_SetupWindow_pulse [position]
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
pulse
$1
EOF
sleep 0.2 #sleeping 0.2 GUI have to read dialog file. see bug #30
}
POL_SetupWindow_set_text ()
{
# Change the pulsebar's text
# Usage POL_SetupWindow_set_text [message]
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
set_text
$1
EOF
sleep 0.2 #sleeping 0.2 GUI have to read dialog file. see bug #30
}
POL_SetupWindow_wait ()
{
# POL_SetupWindow_wait_next_signal in shorter
POL_SetupWindow_wait_next_signal "$@"
}
POL_SetupWindow_download ()
{
# Download a file and place it to the current directory
# Usage: POL_SetupWindow_download [message] [title] [url]
# /!\ Scriptors should directly use POL_Download
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
download
$1
$2
$3
$(pwd)/
EOF
sleep 0.2
DOWNLOADEDFILE=`cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | head -n5 | tail -n1`
DOWNLOADSERVER=`echo $DOWNLOADEDFILE | cut -d/ -f3`
DOWNLOADEDFILE=$(basename "$DOWNLOADEDFILE")
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
exit
fi
}
POL_SetupWindow_textbox ()
{
# Shows a text box
# Usage: POL_SetupWindow_textbox [message] [title] [default value]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
champ
$1
$2
$3
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_browse ()
{
# Shows a text box with a browse button
# Usage: POL_SetupWindow_browse [message] [title] [default value]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
browse
$1
$2
$3
$PWD
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_question ()
{
# Shows a yes/no question
# Usage: POL_SetupWindow_question [message] [title]
# Result is sent in $APP_ANSWER variable (TRUE or FALSE)
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
question
$1
$2
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_QUESTION=')
MESSAGE_TER=${MESSAGE_TER:13}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_menu ()
{
# Shows a menu
# Usage: POL_SetupWindow_menu [message] [title] [list] [separator]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
menu
$1
$2
$3
$4
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_icon_menu ()
{
# Shows a menu with icons
# Usage: POL_SetupWindow_icon_menu [message] [title] [list] [separator] [icons list] [icons folder]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
menu_icons
$1
$2
$3
$4
$5
$6
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_checkbox_list ()
{
# Shows a list of checkbox
# Usage: POL_SetupWindow_checkbox [message] [title] [list] [separator]
# Checked boxes are sent in $APP_ANSWER variable, with the same separator
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
checkbox_list
$1
$2
$3
$4
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_menu_num ()
{
# Shows a menu
# Usage: POL_SetupWindow_menu_num [message] [title] [list] [separator]
# The number of the result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
menu_num
$1
$2
$3
$4
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_menu_list ()
{
# Shows a menu (combobox)
# Usage: POL_SetupWindow_menu [message] [title] [list] [separator]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
menu_list
$1
$2
$3
$4
$5
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_shortcuts_list ()
{
# Shows the shortcut list
# Usage: POL_SetupWindow_shortcuts_list [message] [title]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
get_games
$1
$2
$3
$4
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
export APP_ANSWER="$MESSAGE_TER"
fi
}
POL_SetupWindow_prefix_selector ()
{
# Shows a prefix selector
# Usage : POL_SetupWindow_prefix_selector [message]
# Result is sent in $APP_ANSWER variable
TIMESTAMP="$(date +%s)"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
get_prefixes
$1
$TITLE
$TIMESTAMP
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
while [ ! "$MESSAGE" = "MsgOut" ]
do
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$')
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=')
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_VALUE=')
MESSAGE_TER=${MESSAGE_TER:10}
KINDOF="$(echo $MESSAGE_TER | cut -d";" -f1)"
VALUE="$(echo $MESSAGE_TER | cut -d";" -f2)"
if [ "$KINDOF" = "2" ]
then
export APP_ANSWER="$VALUE"
else
export APP_ANSWER="$(POL_Shortcut_GetPrefix "$VALUE")"
fi
fi
}
POL_SetupWindow_cdrom ()
{
# Shows the cd-rom list to the user
# Usage: POL_SetupWindow_cdrom
# Result is sent to CDROM
# 1 = Numéro du CD
LIST_DEVICES_=""
[ "$POL_OS" = "Mac" ] && DEVICES="/Volumes"
[ "$POL_OS" = "Linux" ] && DEVICES="/media"
cd "$DEVICES"
for device in *
do
if [ ! "$device" = "$LNG_OTHER" ]
then
LIST_DEVICES_+="$device~"
fi
done
LNG_WINE_ASKFORCDROM=$(eval_gettext "Where is mounted your CD-ROM?")
LNG_OTHER=$(eval_gettext "Other")
LNG_REFRESH=$(eval_gettext "Refresh")
POL_SetupWindow_menu "$LNG_WINE_ASKFORCDROM" "$TITLE" "$LIST_DEVICES_$LNG_OTHER~$LNG_REFRESH" "~"
CDROM="$APP_ANSWER"
POL_Debug_Message "CD-ROM selected: $CDROM"
if [ "$CDROM" = "$LNG_OTHER" ]
then
POL_SetupWindow_textbox "$LNG_WINE_ASKFORCDROM" "$TITLE" "$DEVICES/cdrom"
CDROM="$APP_ANSWER"
elif [ "$CDROM" = "$LNG_REFRESH" ]
then
POL_SetupWindow_cdrom
else
CDROMc="$CDROM"
CDROM="$DEVICES/$CDROM"
fi
if [ "$CDROM" = "" ]
then
CDROM="$DEVICES/cdrom"
fi
}
POL_SetupWindow_check_cdrom ()
{
# Checks if the cdrom is valid
# If not, callback to POL_SetupWindow_cdrom
# Usage: POL_SetupWindow_check_cdrom [setup_name.exe]
original_args="$@"
cdrom_found="false"
CDROM_SETUP=""
POL_SetupWindow_wait "$(eval_gettext 'Reading your device')" "$TITLE"
while [ ! "$1" = "" ]; do
if [ ! "$(find "$CDROM" -iwholename "$CDROM/$1")" = "" ]; then
cdrom_found="true"
CDROM_SETUP="$CDROM/$1"
POL_Debug_message "$CDROM/$1 FOUND!"
break
else
POL_Debug_message "$CDROM/$1 not found"
fi
shift
done
if [ "$cdrom_found" = "false" ]; then
POL_Debug_Warning "Unable to find the CD-ROM"
POL_SetupWindow_message "$(eval_gettext "Error: Unable to find the CD-ROM!")" "$TITLE"
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "$original_args"
fi
}
POL_SetupWindow_cdrom_MountPC()
{
if [ "$1" ]; then
if [ ! "$(find "$CDROM" -iwholename "$CDROM/$1")" = "" ]; then
return 0
fi
fi
if [ "$POL_OS" = "Mac" -a "$CDROMc" ]; then
POL_SetupWindow_question "$(eval_gettext '$TITLE needs to read the PC part of a hybrid CD-Rom.\n\nBy default, MacOS only gives you access to the Mac part of the cd-rom, which may not be compatible with recent versions of Mac OS.\n\nDo you want PlayOnMac to attempt to read the PC-Part of your CD?')" "$TITLE"
if [ "$APP_ANSWER" = "TRUE" ]; then
POL_Debug_Message "Trying to mount windows part of $CDROM"
process()
{
search="$1"
read line
while [ "$line" ]; do
if [ "${line::5}" = "/dev/" ]; then
latest_device="$line";
fi
#echo $latest_device
if [ ! "$(grep "${search::16}" <<< $line)" = "" ]; then
echo $latest_device
break
fi
read line;
done
}
device="$(diskutil list | process "$CDROMc")"
rdevice="${device}s1"
POL_Debug_Message "Preparing to mount $rdevice"
POL_SetupWindow_wait "$(eval_gettext 'Please wait...')" "$TITLE"
mount_point="/Volumes/${CDROMc}_Windows"
mkdir "$mount_point"
if mount -t cd9660 "$rdevice" "$mount_point"; then
export CDROM="$mount_point"
export mount_pc_succed="true"
if [ "$1" ]; then
if [ "$(find "$CDROM" -iwholename "$CDROM/$1")" = "" ]; then
POL_Debug_Fatal "Unable to find setup file ($1) on the windows part of the cdrom. Umounting"
POL_SetupWindow_cdrom_UmountPC
fi
fi
else
POL_Debug_Error "Your CD-ROM does not seem to be a hybrid Mac/PC CD-ROM" "$TITLE"
rmdir "$mount_point"
fi
fi
fi
}
POL_SetupWindow_cdrom_UmountPC()
{
if [ "$POL_OS" = "Mac" -a "$CDROMc" -a "$mount_pc_succed" ]; then
POL_Debug_Message "Umounting PC part : $CDROM"
umount "$CDROM"
rmdir "$CDROM"
fi
}
POL_SetupWindow_cdrom_MountMessage ()
{
if [ "$POL_OS" = "Mac" ]; then
POL_SetupWindow_message "$(eval_gettext "Don't forget to go to PlayOnMac tools menu -> Read a PC CD-Rom before running your game")" "$TITLE"
fi
}
POL_SetupWindow_DirectoryProgress ()
{
# Progressbar, by reading a directory size
# Usage: POL_SetupWindow_DirectoryProgress [Directory] [Expected Size] [Pid to check]
# Good for cdrom copy
[ "$3" ] || return 1
[ "$4" ] && cMESSAGE="\n$4"
FICHIER="$1"
POL_SetupWindow_pulsebar "$(eval_gettext 'Please wait while $APPLICATION_TITLE is copying files:')$cMESSAGE" "$TITLE"
POL_SetupWindow_pulse 0
while [ ! "$(ps aux | awk '{print $2}' | grep $3)" = "" ]; do
current_size="$(du "$1"| tail -n 1 | awk '{print $1}')"
current_perc=$(( 100 * $current_size / $2 ))
POL_SetupWindow_pulse "$current_perc"
sleep 1
done
POL_SetupWindow_pulse 100
return 0
}
POL_GetSetupImages () # ( optional : --erase )
{
# This function helps you to manage your setup images
# It will download images only once, except if you use --erase
#
# 1 - Top image url
# 2 - Left image url
# 3 - Name (only alpha-numerical please)
#
# Path of images are returned in $POL_SetupWindow_LeftImage and $POL_SetupWindow_TopImage
if [ "$1" == "--force" ]
then
left="$3"
top="$2"
name="$4"
else
left="$2"
top="$1"
name="$3"
fi
mkdir -p "$POL_USER_ROOT/configurations/setups/$name"
cd "$POL_USER_ROOT/configurations/setups/$name"
if [ "$top" == "" ]
then
export POL_SetupWindow_TopImage="$PLAYONLINUX/etc/setups/default/top.png"
elif [ "$1" == "--force" ] || [ ! -e "top" ]
then
$POL_WGET --timeout=10 "$top" -O top 2> /dev/null && POL_SetupWindow_TopImage="$PWD/top" || export POL_SetupWindow_TopImage="$PLAYONLINUX/etc/setups/default/top.png"
if [ "$POL_SetupWindow_TopImage" = "$PLAYONLINUX/etc/setups/default/top.png" ]
then
rm -f top
fi
else
POL_SetupWindow_TopImage="$PWD/top"
fi
if [ "$left" == "" ]
then
export POL_SetupWindow_LeftImage="$PLAYONLINUX/etc/setups/default/left.jpg"
elif [ "$1" == "--force" ] || [ ! -e "left" ]
then
$POL_WGET --timeout=10 "$left" -O left 2> /dev/null && POL_SetupWindow_LeftImage="$PWD/left" || export POL_SetupWindow_LeftImage="$PLAYONLINUX/etc/setups/default/left.jpg"
if [ "$POL_SetupWindow_LeftImage" = "$PLAYONLINUX/etc/setups/default/left.jpg" ]
then
rm -f left
fi
else
POL_SetupWindow_LeftImage="$PWD/left"
fi
cd "$OLDPWD"
}
POL_SetupWindow_InitWithImages ()
{
# This function is identical than POL_SetupWindow_Init, excepts that it uses images defined in POL_GetSetupImages
# Usage: POL_SetupWindow_InitWithImages
POL_SetupWindow_Init "$POL_SetupWindow_TopImage" "$POL_SetupWindow_LeftImage"
}
POL_SetupWindow_login ()
{
# This function shows a login windows for PlayOnLinux's website
# Usage: POL_SetupWindow_login "Message" "Title" "Register link"
if [ "$POL_OS" = "Mac" ]; then
register_link="http://www.playonmac.com/en/register.html"
else
register_link="http://www.playonlinux.com/en/register.html"
fi
[ "$3" = "" ] || register_link="$3"
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
Login
$1
$2
$register_link
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$' 2> /dev/null)
while [ ! "$MESSAGE" = "MsgOut" ]
do
[ ! -e "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" ] && exit
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$' 2> /dev/null)
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=' 2> /dev/null)
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^LOGIN=' 2> /dev/null)
MESSAGE_TER=${MESSAGE_TER:6}
export POL_LOGIN="$MESSAGE_TER"
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^PASS=' 2> /dev/null)
MESSAGE_TER=${MESSAGE_TER:5}
export POL_PASSWORD="$MESSAGE_TER"
fi
}
POL_SetupWindow_file ()
{
# Shows the content of a file
# Usage: POL_SetupWindow_file [message] [title] [file]
if [ -f "$3" ]
then
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
file
$1
$2
$3
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$' 2> /dev/null)
while [ ! "$MESSAGE" = "MsgOut" ]
do
[ ! -e "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" ] && exit
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$' 2> /dev/null)
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=' 2> /dev/null)
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
fi
fi
}
POL_SetupWindow_textbox_multiline ()
{
# Same than POL_SetupWindow_textbox, except that it accepts multiline
# Usage: POL_SetupWindow_textbox_multiline [message] [title] [default value]
cat << EOF > "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
MsgIn
bigchamp
$1
$2
$3
EOF
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$' 2> /dev/null)
while [ ! "$MESSAGE" = "MsgOut" ]
do
[ ! -e "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" ] && exit
MESSAGE=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MsgOut$' 2> /dev/null)
sleep 0.1
done
MESSAGE_BIS=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID" | grep '^MSG_RECEIVED=' 2> /dev/null)
if [ "$MESSAGE_BIS" = "MSG_RECEIVED=Cancel" ]
then
rm "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID"
exit
else
MESSAGE_TER=$(cat "$REPERTOIRE/configurations/guis/$POL_SetupWindow_ID.txt")
export APP_ANSWER="$MESSAGE_TER"
fi
}
process_POL_SetupWindow_show_exe ()
{
### Used by POL_SetupWindow_show_exe
read line
first=true
while [ ! "$line" = "" ]
do
[ "$first" = "true" ] && first=false || printf "~"
printf "$(basename "$line")"
read line
done
}
POL_SetupWindow_show_exe ()
{
# Show the list of non-wine .exe file in the current prefix
# Usage : POL_SetupWindow_show_exe
cd "$WINEPREFIX/drive_c"
POL_SetupWindow_wait_next_signal "$(eval_gettext "Scanning the virtual drive ...")" "$2"
contents="$(find . -name windows -prune -o -name iexplore.exe -prune -o -iname '*.exe' -a -type f -print | process_POL_SetupWindow_show_exe)"
POL_SetupWindow_menu "$1" "$2" "$contents" "~"
}
POL_SetupWindow_VMS ()
{
# Ask the user how much memory does his graphic board have, and store it to POL config file
# Usage: POL_SetupWindow_VMS [minimum memory]
[ "$WINEPREFIX" = "" ] && POL_Debug_Fatal "WINEPREFIX is not set !"
VMS="$(POL_Config_Read VMS)"
if [ "$VMS" = "" ]
then
POL_SetupWindow_menu "$(eval_gettext "How much memory does your graphics board have?")" "$TITLE" "64-128-256-320-384-512-640-768-896-1024-1536-1792-2048-3072-4096" "-"
VMS="$APP_ANSWER"
POL_Config_Write VMS $APP_ANSWER
fi
POL_Wine_Direct3D "VideoMemorySize" "$VMS"
if [ ! "$1" = "" ]
then
if [ $VMS -lt $1 ]
then
POL_Debug_Warning "$(eval_gettext "Video card does not have enough memory")" "$TITLE"
POL_SetupWindow_Message "$(eval_gettext "Your video card does not have enough memory!\nIt might prevent the game from working")" "$TITLE"
fi
fi
}
POL_SetupWindow_InstallMethod()
{
# Shows a list of install methods
# Usage: POL_SetupWindow_InstallMethod [List]
# Elements in list are separated by a coma
# Accepted methods are STEAM, STEAM_DEMO, LOCAL, CD, DVDROM, DOWNLOAD, ORIGIN, ORIGIN_DEMO, DESURA, DESURA_DEMO
[ "$1" = "" ] && POL_Debug_Fatal "No method in list"
STR=""
ICO=""
LNG_STEAM="$(eval_gettext "Use Steam Store version")"
LNG_STEAM_DEMO="$(eval_gettext "Use Steam Store demo version")"
LNG_DESURA="$(eval_gettext "Use Desura Store version")"
LNG_DESURA_DEMO="$(eval_gettext "Use Desura Store demo version")"
LNG_ORIGIN="$(eval_gettext "Use Origin Store version")"
LNG_ORIGIN_DEMO="$(eval_gettext "Use Origin Store demo version")"
LNG_LOCAL="$(eval_gettext "Use a setup file in my computer")"
LNG_CDROM="$(eval_gettext "Use CD-ROM(s)")"
LNG_DVD="$(eval_gettext "Use DVD-ROM(s)")"
LNG_DOWNLOAD="$(eval_gettext "Download the program")"
if [ ! "$(printf "$1" | grep LOCAL)" = "" ]
then
STR="$STR~$LNG_LOCAL"
ICO="$ICO~browse.png"
fi
if [ ! "$(printf "$1" | grep CD)" = "" ]
then
STR="$STR~$LNG_CDROM"
ICO="$ICO~cdrom.png"
fi
if [ ! "$(printf "$1" | grep DVD)" = "" ]
then
STR="$STR~$LNG_DVD"
ICO="$ICO~cdrom.png"
fi
if [ ! "$(printf "$1" | grep STEAM)" = "" ]
then
STR="$STR~$LNG_STEAM"
ICO="$ICO~download.png"
fi
if [ ! "$(printf "$1" | grep STEAM_DEMO)" = "" ]
then
STR="$STR~$LNG_STEAM_DEMO"
ICO="$ICO~download.png"
fi
if [ ! "$(printf "$1" | grep DESURA)" = "" ]
then
STR="$STR~$LNG_DESURA"
ICO="$ICO~download.png"
fi
if [ ! "$(printf "$1" | grep DESURA_DEMO)" = "" ]
then
STR="$STR~$LNG_DESURA_DEMO"
ICO="$ICO~download.png"
fi
if [ ! "$(printf "$1" | grep ORIGIN)" = "" ]
then
STR="$STR~$LNG_ORIGIN"
ICO="$ICO~download.png"
fi
if [ ! "$(printf "$1" | grep ORIGIN_DEMO)" = "" ]
then
STR="$STR~$LNG_ORIGIN_DEMO"
ICO="$ICO~download.png"
fi
if [ ! "$(printf "$1" | grep DOWNLOAD)" = "" ]
then
STR="$STR~$LNG_DOWNLOAD"
ICO="$ICO~download.png"
fi
STR="${STR:1}"
ICO="${ICO:1}"
mkdir -p "$POL_USER_ROOT/tmp/cache/icons/InstallMethod"
cp "$PLAYONLINUX/resources/images/icones/browse.png" "$POL_USER_ROOT/tmp/cache/icons/InstallMethod"
cp "$PLAYONLINUX/resources/images/icones/cdrom.png" "$POL_USER_ROOT/tmp/cache/icons/InstallMethod"
cp "$PLAYONLINUX/resources/images/icones/download.png" "$POL_USER_ROOT/tmp/cache/icons/InstallMethod"
POL_SetupWindow_icon_menu "$(eval_gettext "Please choose an installation method")" "$TITLE" "$STR" "~" "$POL_USER_ROOT/tmp/cache/icons/InstallMethod" "$ICO"
# Si l'utilisateur n'a rien choisi
if [ "$APP_ANSWER" = "" ]
then
POL_SetupWindow_InstallMethod "$@"
return
fi
[ "$APP_ANSWER" = "$LNG_LOCAL" ] && INSTALL_METHOD="LOCAL"
[ "$APP_ANSWER" = "$LNG_STEAM" ] && INSTALL_METHOD="STEAM"
[ "$APP_ANSWER" = "$LNG_STEAM_DEMO" ] && INSTALL_METHOD="STEAM_DEMO"
[ "$APP_ANSWER" = "$LNG_DESURA" ] && INSTALL_METHOD="DESURA"
[ "$APP_ANSWER" = "$LNG_DESURA_DEMO" ] && INSTALL_METHOD="DESURA_DEMO"
[ "$APP_ANSWER" = "$LNG_ORIGIN" ] && INSTALL_METHOD="ORIGIN"
[ "$APP_ANSWER" = "$LNG_ORIGIN_DEMO" ] && INSTALL_METHOD="ORIGIN_DEMO"
[ "$APP_ANSWER" = "$LNG_DOWNLOAD" ] && INSTALL_METHOD="DOWNLOAD"
[ "$APP_ANSWER" = "$LNG_DVD" ] && INSTALL_METHOD="DVD"
[ "$APP_ANSWER" = "$LNG_CDROM" ] && INSTALL_METHOD="CD"
POL_Debug_Message "Install method: $INSTALL_METHOD"
}
POL_SetupWindow_shortcut_creator()
{
# Shows a shortcut creator
# Usage: POL_SetupWindow_shortcut_creator
# No argument, this function uses WINEPREFIX
[ "$WINEPREFIX" = "" ] && POL_Debug_Fatal "POL_SetupWindow_shortcut_creator : wineprefix not set"
existing="$(get_existing_POL_SetupWindow_shortcut_creator)"
cd "$WINEPREFIX/drive_c"
CODENAME="$(POL_MD5 "$WINEPREFIX")"
mkdir -p "$POL_USER_ROOT/tmp/cache/icons/$CODENAME"
cp "$PLAYONLINUX/resources/images/icones/browse.png" "$POL_USER_ROOT/tmp/cache/icons/$CODENAME"
cp "$PLAYONLINUX/resources/images/icones/finish.png" "$POL_USER_ROOT/tmp/cache/icons/$CODENAME"
POL_SetupWindow_wait_next_signal "$(eval_gettext "Scanning the virtual drive ...")" "$TITLE"
contents="$(find . -name windows -prune -o -name iexplore.exe -prune -o -iname '*.exe' -a -type f -print | process_POL_SetupWindow_shortcut_creator)"
LNG_FINISH="$(eval_gettext "I don't want to make another shortcut")"
LNG_BROWSE="$(eval_gettext "Browse")"
[ "$contents" = "" ] || CONTENTS2="~$contents"
POL_SetupWindow_icon_menu "$(eval_gettext "Please choose a file for $APPLICATION_TITLE to make a shortcut")" "$TITLE" "$LNG_FINISH~$LNG_BROWSE$CONTENTS2" "~" "$POL_USER_ROOT/tmp/cache/icons/$CODENAME" "finish.png~browse.png$CONTENTS2"
EXE_FILE=""
if [ "$APP_ANSWER" = "$LNG_BROWSE" ]
then
cd $WINEPREFIX/drive_c || POL_Debug_Fatal "Prefix : $WINEPREFIX does not exist"
POL_SetupWindow_browse "$(eval_gettext "Please choose a file for $APPLICATION_TITLE to make a shortcut")" "$TITLE"
EXE_FILE="$(basename "$APP_ANSWER")"
elif [ ! "$APP_ANSWER" = "$LNG_FINISH" ]
then
EXE_FILE="$APP_ANSWER"
fi
if [ ! "$EXE_FILE" = "" ]
then
POL_SetupWindow_textbox "$(eval_gettext "Please choose a shortcut name for $EXE_FILE")" "$TITLE"
TITRE="$APP_ANSWER"
POL_Shortcut "$EXE_FILE" "$TITRE"
echo "POL_Shortcut \"$EXE_FILE\" \"$TITRE\"" >> "$POL_USER_ROOT/tmp/shortcuts"
POL_SetupWindow_shortcut_creator
fi
}
process_POL_SetupWindow_shortcut_creator ()
{
### Used by POL_SetupWindow_shortcut_creator
read line
first=true
while [ ! "$line" = "" ]
do
if [ "$(echo $existing | grep $(basename "$line"))" = "" ]
then
#echo "On tente d'extraire $WINEPREFIX/drive_c/$line"
POL_ExtractIcon "$WINEPREFIX/drive_c/$line" "$POL_USER_ROOT/tmp/cache/icons/$CODENAME/$(basename "$line")" 2> /dev/null > /dev/null
# Si il parle il fiche tout en l'air
[ "$first" = "true" ] && first=false || printf "~"
printf "$(basename "$line")"
fi
read line
done
}
get_existing_POL_SetupWindow_shortcut_creator()
{
### Used by POL_SetupWindow_shortcut_creator
cd "$REPERTOIRE/shortcuts"
for file in *
do
if [ ! "$(cat "$file" | grep $WINEPREFIX)" = "" ]
then
cat "$file" | grep "POL_Wine " | awk '{print $2}' | tr -d "\""
fi
done
}
|