ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.186 by elmex, Wed Jul 25 15:06:21 2007 UTC vs.
Revision 1.187 by elmex, Fri Jul 27 18:04:43 2007 UTC

177our $INV; 177our $INV;
178our $INVR; 178our $INVR;
179our $INV_RIGHT_HB; 179our $INV_RIGHT_HB;
180 180
181our $PICKUP_CFG; 181our $PICKUP_CFG;
182
183our $IN_BUILD_MODE;
184our $BUILD_BUTTON;
185 182
186sub status { 183sub status {
187 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 184 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
188} 185}
189 186
1804 $BUTTONBAR->show; 1801 $BUTTONBAR->show;
1805 $SETUP_DIALOG->show; 1802 $SETUP_DIALOG->show;
1806 } 1803 }
1807 1804
1808 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 1805 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
1809}
1810
1811sub setup_build_button {
1812 my ($enabled) = @_;
1813 if ($enabled) {
1814 $BUILD_BUTTON->hide if $BUILD_BUTTON;
1815 $BUILD_BUTTON ||= new CFPlus::UI::Button
1816 text => "Build",
1817 tooltip => "Opens the ingame builder",
1818 on_activate => sub {
1819 if ($CONN) {
1820 $CONN->send_ext_req (builder_player_items => sub {
1821 open_ingame_editor ($_[0]) if exists $_[0]->{items};
1822 });
1823 }
1824 0
1825 };
1826 $BUTTONBAR->add ($BUILD_BUTTON);
1827 } else {
1828 $BUILD_BUTTON->hide if $BUILD_BUTTON;
1829 }
1830}
1831
1832sub open_ingame_editor {
1833 my ($msg) = @_;
1834
1835 my $win = new CFPlus::UI::Toplevel
1836 x => 0,
1837 y => 'center',
1838 z => 4,
1839 name => 'builder_window',
1840 force_w => int $WIDTH * 1/4,
1841 force_h => int $HEIGHT * 3/4,
1842 title => "In game builder",
1843 has_close_button => 1;
1844
1845 my $r = new CFPlus::UI::ScrolledWindow (
1846 expand => 1,
1847 scroll_y => 1
1848 );
1849 $r->add (my $vb = new CFPlus::UI::VBox);
1850 $win->add ($r);
1851
1852
1853 $vb->add (
1854 new CFPlus::UI::Button
1855 text => "Disable build mode",
1856 on_activate => sub { $::IN_BUILD_MODE = undef }
1857 );
1858 $vb->add (
1859 new CFPlus::UI::Button
1860 text => "ERASE",
1861 on_activate => sub { $::IN_BUILD_MODE = { do_erase => 1 } }
1862 );
1863
1864 for my $itemarchname (
1865 sort {
1866 $msg->{items}->{$a}->{build_arch_name}
1867 cmp $msg->{items}->{$b}->{build_arch_name}
1868 } keys %{$msg->{items}}
1869 ) {
1870 my $info = $msg->{items}->{$itemarchname};
1871 $vb->add (
1872 new CFPlus::UI::Button text => $info->{build_arch_name},
1873 on_activate => sub {
1874 $::IN_BUILD_MODE = { item => $itemarchname, info => $info };
1875
1876 if (grep { $msg->{items}->{$itemarchname}->{$_} } qw/has_connection has_name has_text/) {
1877 build_mode_query_arch_info ();
1878 }
1879 }
1880 );
1881 }
1882
1883 $win->show;
1884}
1885
1886sub build_mode_query_arch_info {
1887 my ($iteminfo) = $::IN_BUILD_MODE;
1888 my $itemarchname = $iteminfo->{item};
1889 my $info = $iteminfo->{info};
1890
1891 my $dialog = new CFPlus::UI::Toplevel
1892 x => "center",
1893 y => "center",
1894 z => 50,
1895 force_w => int $WIDTH * 1/2,
1896 title => "Enter information for placement of '$itemarchname'",
1897 has_close_button => 1;
1898
1899 $dialog->add (my $vb = new CFPlus::UI::VBox expand => 1);
1900
1901 $vb->add (my $table = new CFPlus::UI::Table expand => 1);
1902 my $row = 0;
1903 if ($info->{has_name}) {
1904 $table->add_at (0, $row, new CFPlus::UI::Label text => "Name:");
1905 $table->add_at (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{name} = $_[1]; 0 });
1906 }
1907 if ($info->{has_text}) {
1908 $table->add_at (0, $row, new CFPlus::UI::Label text => "Text:");
1909 $table->add_at (1, $row++, new CFPlus::UI::Entry expand => 1, on_changed => sub { $::IN_BUILD_MODE->{text} = $_[1]; 0 });
1910 }
1911 if ($info->{has_connection}) {
1912 $table->add_at (0, $row, new CFPlus::UI::Label text => "Connection ID:");
1913 $table->add_at (1, $row++,
1914 new CFPlus::UI::Entry
1915 expand => 1,
1916 on_changed => sub { $::IN_BUILD_MODE->{connection} = $_[1]; 0 },
1917 tooltip => "Enter the connection ID here. The connection ID connects actors like a lever to a gate or a magic ear to a gate"
1918 );
1919 }
1920
1921 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1);
1922 $hb->add (new CFPlus::UI::Button
1923 text => "Close",
1924 expand => 1,
1925 on_activate => sub { $dialog->hide; 0 },
1926 );
1927 $dialog->show;
1928} 1806}
1929 1807
1930sub video_shutdown { 1808sub video_shutdown {
1931 CFPlus::OpenGL::shutdown; 1809 CFPlus::OpenGL::shutdown;
1932 1810

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines