… | |
… | |
149 | |
149 | |
150 | our $BIND_EDITOR; |
150 | our $BIND_EDITOR; |
151 | our $BIND_UPD_CB; |
151 | our $BIND_UPD_CB; |
152 | |
152 | |
153 | our $PICKUP_CFG; |
153 | our $PICKUP_CFG; |
|
|
154 | |
|
|
155 | our $IN_BUILD_MODE; |
|
|
156 | our $BUILD_BUTTON; |
154 | |
157 | |
155 | sub status { |
158 | sub status { |
156 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
159 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
157 | } |
160 | } |
158 | |
161 | |
… | |
… | |
1862 | ); |
1865 | ); |
1863 | |
1866 | |
1864 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
1867 | $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, |
1865 | tooltip => "View Documentation"); |
1868 | tooltip => "View Documentation"); |
1866 | |
1869 | |
|
|
1870 | |
1867 | $BUTTONBAR->add (new CFPlus::UI::Button |
1871 | $BUTTONBAR->add (new CFPlus::UI::Button |
1868 | text => "Quit", |
1872 | text => "Quit", |
1869 | tooltip => "Terminates the program", |
1873 | tooltip => "Terminates the program", |
1870 | on_activate => sub { |
1874 | on_activate => sub { |
1871 | if ($CONN) { |
1875 | if ($CONN) { |
… | |
… | |
1880 | $BUTTONBAR->show; |
1884 | $BUTTONBAR->show; |
1881 | $SETUP_DIALOG->show; |
1885 | $SETUP_DIALOG->show; |
1882 | } |
1886 | } |
1883 | |
1887 | |
1884 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
1888 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
|
|
1889 | } |
|
|
1890 | |
|
|
1891 | sub setup_build_button { |
|
|
1892 | my ($enabled) = @_; |
|
|
1893 | if ($enabled) { |
|
|
1894 | $BUILD_BUTTON ||= new CFPlus::UI::Button |
|
|
1895 | text => "Build", |
|
|
1896 | tooltip => "Opens the ingame builder", |
|
|
1897 | on_activate => sub { |
|
|
1898 | if ($CONN) { |
|
|
1899 | $CONN->send_ext_req (builder_player_items => sub { |
|
|
1900 | open_ingame_editor ($_[0]) if exists $_[0]->{items}; |
|
|
1901 | }); |
|
|
1902 | } |
|
|
1903 | 0 |
|
|
1904 | }; |
|
|
1905 | $BUTTONBAR->add ($BUILD_BUTTON); |
|
|
1906 | } else { |
|
|
1907 | $BUILD_BUTTON->hide if $BUILD_BUTTON; |
|
|
1908 | } |
|
|
1909 | } |
|
|
1910 | |
|
|
1911 | sub open_ingame_editor { |
|
|
1912 | my ($msg) = @_; |
|
|
1913 | |
|
|
1914 | my $win = new CFPlus::UI::Toplevel |
|
|
1915 | x => 0, |
|
|
1916 | y => 'center', |
|
|
1917 | z => 4, |
|
|
1918 | name => 'builder_window', |
|
|
1919 | force_w => int $WIDTH * 1/4, |
|
|
1920 | force_h => int $HEIGHT * 3/4, |
|
|
1921 | title => "In game builder", |
|
|
1922 | has_close_button => 1; |
|
|
1923 | |
|
|
1924 | my $r = new CFPlus::UI::ScrolledWindow ( |
|
|
1925 | expand => 1, |
|
|
1926 | scroll_y => 1 |
|
|
1927 | ); |
|
|
1928 | $r->add (my $vb = new CFPlus::UI::VBox); |
|
|
1929 | $win->add ($r); |
|
|
1930 | |
|
|
1931 | |
|
|
1932 | $vb->add (my $chk = new CFPlus::UI::Button text => "Disable build mode", on_activate => sub { $::IN_BUILD_MODE = undef }); |
|
|
1933 | $vb->add (my $chk = new CFPlus::UI::Button text => "ERASE", on_activate => sub { $::IN_BUILD_MODE = { do_erase => 1 } }); |
|
|
1934 | |
|
|
1935 | for my $itemarchname (keys %{$msg->{items}}) { |
|
|
1936 | $vb->add ( |
|
|
1937 | new CFPlus::UI::Button text => "$itemarchname", |
|
|
1938 | on_activate => sub { |
|
|
1939 | $::IN_BUILD_MODE = $itemarchname; |
|
|
1940 | } |
|
|
1941 | ); |
|
|
1942 | } |
|
|
1943 | |
|
|
1944 | $win->show; |
1885 | } |
1945 | } |
1886 | |
1946 | |
1887 | sub video_shutdown { |
1947 | sub video_shutdown { |
1888 | CFPlus::OpenGL::shutdown; |
1948 | CFPlus::OpenGL::shutdown; |
1889 | |
1949 | |